Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AD0001 Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.ArgumentException' with message 'Unhandled declaration kind: RecordDeclaration'. #3359

Closed
linkdotnet opened this issue Jun 30, 2021 · 2 comments

Comments

@linkdotnet
Copy link

With the latest StyleCop.Analyzers version (1.1.118) SA1649 fires an ArgumentException when analyzing records in NET5 (C# 9).

Error

AD0001 Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.ArgumentException' with message 'Unhandled declaration kind: RecordDeclaration'.

Steps to reproduce

  1. Create a new project (for example Blazor Server App) with .NET5 as target framework
  2. Install dependency to StyleCop.Analyzers
  3. Change the WeatherData class to a record like below (or just create a new record class)
public record WeatherForecast
{
    public DateTime Date { get; init; }

    public int TemperatureC { get; init; }

    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

    public string Summary { get; init; }
}
  1. Configure StyleCop in that fashion that it throws a message (for example warning) for SA1649
  2. Hit compile

For a complete example checkout: https://github.com/linkdotnet/StyleCopError

Clone / download the repo and press compile.

@linkdotnet
Copy link
Author

1.1.118 only supports until 7.3

@sharwell
Copy link
Member

Duplicate of #3213

@sharwell sharwell marked this as a duplicate of #3213 Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants