Respect ReportSuppressedDiagnostics option for DiagnosticSuppressor#53045
Respect ReportSuppressedDiagnostics option for DiagnosticSuppressor#53045mavasani merged 9 commits intodotnet:mainfrom
Conversation
mavasani
left a comment
There was a problem hiding this comment.
This compilation option is not to determine whether or not diagnostic suppressors should run. The option indicates whether or suppressed diagnostics should be filtered out from final diagnostics output. Basically, this option is unrelated to suppressors.
|
I mentioned this in #52953. The current program executes following steps if this option is true.
In 3rd step, |
|
What I understand from the PR is that currently, ReportSuppressedDiagnostics isn't respected for DiagnosticSuppressors. However, I see DiagnosticSuppressor tests in roslyn-analyzers relying on ReportSuppressedDiagnostics property. Not sure what's going on? Edit: I see tthe tests are skipped. |
|
I agree with the analysis in #53045 (comment). This oversight is the main reason we don't have any support for testing diagnostic suppressors in Microsoft.CodeAnalysis.Testing. |
FYI - I managed to write tests for suppressors before. dotnet/efcore#24151 (might not be the best way - but you may be able to use a similar idea for roslyn-sdk until this PR is merged and shipped) |
|
The implementation in this PR is wrong, the filtering is done at the wrong place. Note that without your change, all programmatically suppressed diagnostics from suppressors will always go through the below code path and info diagnostics will be reported in binary logs for them, regardless of the value of this option: roslyn/src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs Lines 560 to 571 in a6b8bb5 With your change, this will no longer be true when The correct fix here would be to revert your changes and move out the filtering to be done just after the callsite inside Also, please add unit tests for this change. |
|
@mavasani Wouldn't that make the method |
|
@Youssef1313 Naming is a minor thing for a private method. We cannot cause a functionality break for the most important requirement in the DiagnosticSuppressor design. |
|
@mavasani Yeah certainly. I meant that we could rename it as a minor cleanup. |
|
@mavasani Thank you for the review. I'll fix the implementation of |
|
@mavasani I have rewrited the implementation and add some tests. |
|
@mavasani Could you re-review this? |
|
@mavasani Can you take a look please? Thanks! |
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
Outdated
Show resolved
Hide resolved
mavasani
left a comment
There was a problem hiding this comment.
Looks good to me. I have couple of suggestions to further simplify the code changes.
|
@dotnet/roslyn-compiler for reviews |
Co-authored-by: Manish Vasani <mavasani@microsoft.com>
|
@dotnet/roslyn-compiler for a second compiler review. |
|
@dotnet/roslyn-compiler for second review. |
This PR fixes #41584.
Diagnostics suppressed programatically by DiagnosticSuppressor were not excluded properly when ReportSuppressedDiagnostics option is set to true.