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

Record structs in C# 10 is throwing an argument exception in SA1649 #3395

Closed
twsouthwick opened this issue Oct 21, 2021 · 3 comments · Fixed by #3401
Closed

Record structs in C# 10 is throwing an argument exception in SA1649 #3395

twsouthwick opened this issue Oct 21, 2021 · 3 comments · Fixed by #3401

Comments

@twsouthwick
Copy link

With the latest version (1.2.0-beta.354) I'm hitting an error when using a record struct:

namespace Something
{
  public readonly record struct Sometype(
  {
    public bool IsSet { get; init; }
  }

I'm getting the following error:

Analyzer 'StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName' threw an exception of type 'System.ArgumentException' with message 'Unhandled declaration kind: RecordStructDeclaration'.
@sharwell
Copy link
Member

This is very similar to #3213 but affects RecordStructDeclaration. Since this change will require a new test project for C# 10 it could be fairly involved.

@twsouthwick
Copy link
Author

I took a look at the project structure and saw that there are different projects for the different language versions. I'm happy to provide a fix for this if you can point me to any docs on how to structure the language version projects

@AArnott
Copy link
Contributor

AArnott commented Nov 9, 2021

I'm going to have to turn SA1649 completely off for my project because a simple #pragma warning disable SA1649 in the file is evidently insufficient to suppress the AD0001 warning being emitted by the compiler.

@sharwell sharwell self-assigned this Nov 10, 2021
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Nov 10, 2021
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Nov 10, 2021
@sharwell sharwell added this to the 1.2-beta.next milestone Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants