When CompilationWithAnalyzersOptions.ReportSuppressedDiagnostics is set to true,
CompilationWithAnalyzers doesn't return diagnostics suppressed by pragma or SuppressMessageAttribute,
but return diagnostics suppressed by DiagnosticSuppressors.
The docs for ReportSuppressedDiagnostics say this flag filters diagnostics with IsSuppressed.
Diagnostics suppressed by DiagnosticSuppressors also have IsSuppressed, so I think the docs or the implementation must be corrected.
Example code:
var compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, new CompilationWithAnalyzersOptions(
options,
onAnalyzerException: null,
concurrentAnalysis: false,
logAnalyzerExecutionTime: false,
reportSuppressedDiagnostics: false)); // here
var diagnostics = await compilationWithAnalyzers
.GetAnalyzerSemanticDiagnosticsAsync(semanticModel, filterSpan: null, cancellationToken);
Expected Behavior:
diagnostics don't include any diagnostics suppressed by DiagnosticSuppressors.
Actual Behavior:
diagnostics include diagnostics suppressed by DiagnosticSuppressors.
When
CompilationWithAnalyzersOptions.ReportSuppressedDiagnosticsis set to true,CompilationWithAnalyzers doesn't return diagnostics suppressed by pragma or SuppressMessageAttribute,
but return diagnostics suppressed by DiagnosticSuppressors.
The docs for ReportSuppressedDiagnostics say this flag filters diagnostics with
IsSuppressed.Diagnostics suppressed by DiagnosticSuppressors also have
IsSuppressed, so I think the docs or the implementation must be corrected.Example code:
Expected Behavior:
diagnosticsdon't include any diagnostics suppressed by DiagnosticSuppressors.Actual Behavior:
diagnosticsinclude diagnostics suppressed by DiagnosticSuppressors.