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

SA1600 is not raised for record primary constructors that are missing param tags #3780

Open
SapiensAnatis opened this issue Jan 16, 2024 · 2 comments · May be fixed by #3783
Open

SA1600 is not raised for record primary constructors that are missing param tags #3780

SapiensAnatis opened this issue Jan 16, 2024 · 2 comments · May be fixed by #3783

Comments

@SapiensAnatis
Copy link
Contributor

Today, the following code will not cause any Stylecop diagnostics to be raised:

/// <summary>
/// Record.
/// </summary>
public record MyRecord(int Parameter);

This is in spite of the missing <param> tag for Parameter. Stylecop should report a diagnostic unless this is included:

/// <summary>
/// Record.
/// </summary>
/// <param name="Parameter">Parameter.</param>
public record MyRecord(int Parameter);

Because Parameter declares a property as well as a constructor parameter, it was agreed in #3770 that it should report SA1600 instead of the usual SA1611 for missing <param> tags.

@SapiensAnatis
Copy link
Contributor Author

I've made some initial progress towards tackling this issue, but am currently dealing with a strange problem where my test is reporting each diagnostic twice 😔

I get this output for a record like the one in the example above that declares a single undocumented parameter:

Microsoft.CodeAnalysis.Testing.Verifiers.EqualWithMessageException : Context: Diagnostics of test state
Mismatch between number of diagnostics returned, expected "1" actual "2"
    
Diagnostics:
// /0/Test0.cs(5,28): warning SA1600: Elements should be documented
VerifyCS.Diagnostic().WithSpan(5, 28, 5, 34),
// /0/Test0.cs(5,28): warning SA1600: Elements should be documented
VerifyCS.Diagnostic().WithSpan(5, 28, 5, 34),

I won't make this a huge comment containing everything I've done (I could open a draft PR if need be) but it seems when I debug the tests all my breakpoints are hit twice. This seems to happen with other analyzers as well. I was wondering if that could be the cause, or is this normal when testing analyzers?

@sharwell
Copy link
Member

I think there are some versions of Roslyn where callbacks execute twice, resulting in duplicate diagnostics. You can include the diagnostic twice in the expected results and I can investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants