diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs index 4b1adefbb858d..63c7e533907ee 100644 --- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs +++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs @@ -9353,13 +9353,14 @@ public void ReportAnalyzerOutput() responseFile: null, srcDirectory, new[] { "/reportanalyzer", "/t:library", srcFile.Path }, - analyzers: new[] { new WarningDiagnosticAnalyzer() }, + analyzers: [new WarningDiagnosticAnalyzer(), new DiagnosticSuppressorForId("Warning01", "Suppressor01")], generators: new[] { new DoNothingGenerator().AsSourceGenerator() }); var exitCode = csc.Run(outWriter); Assert.Equal(0, exitCode); var output = outWriter.ToString(); Assert.Contains(CodeAnalysisResources.AnalyzerExecutionTimeColumnHeader, output, StringComparison.Ordinal); Assert.Contains($"{nameof(WarningDiagnosticAnalyzer)} (Warning01)", output, StringComparison.Ordinal); + Assert.Contains($"{nameof(DiagnosticSuppressorForId)} (Suppressor01)", output, StringComparison.Ordinal); Assert.Contains(CodeAnalysisResources.GeneratorNameColumnHeader, output, StringComparison.Ordinal); Assert.Contains(typeof(DoNothingGenerator).FullName, output, StringComparison.Ordinal); CleanupAllGeneratedFiles(srcFile.Path); diff --git a/src/Compilers/Core/Portable/CommandLine/ReportAnalyzerUtil.cs b/src/Compilers/Core/Portable/CommandLine/ReportAnalyzerUtil.cs index 0cc9e6c857c83..218fc34d16cd8 100644 --- a/src/Compilers/Core/Portable/CommandLine/ReportAnalyzerUtil.cs +++ b/src/Compilers/Core/Portable/CommandLine/ReportAnalyzerUtil.cs @@ -93,7 +93,7 @@ private static void ReportAnalyzerExecutionTime(TextWriter consoleOutput, Analyz executionTime = kvp.Value.TotalSeconds; percentage = (int)(executionTime * 100 / totalAnalyzerExecutionTime); - var analyzerIds = string.Join(", ", kvp.Key.SupportedDiagnostics.Select(d => d.Id).Distinct().OrderBy(id => id)); + var analyzerIds = string.Join(", ", GetSupportedIds(kvp.Key).Distinct().OrderBy(id => id)); var analyzerNameColumn = $" {kvp.Key} ({analyzerIds})"; consoleOutput.WriteLine(GetColumnEntry(executionTime, percentage, analyzerNameColumn, culture)); } @@ -102,6 +102,13 @@ private static void ReportAnalyzerExecutionTime(TextWriter consoleOutput, Analyz } } + private static IEnumerable GetSupportedIds(DiagnosticAnalyzer analyzer) + => analyzer switch + { + DiagnosticSuppressor suppressor => suppressor.SupportedSuppressions.Select(s => s.Id), + _ => analyzer.SupportedDiagnostics.Select(d => d.Id), + }; + private static void ReportGeneratorExecutionTime(TextWriter consoleOutput, GeneratorDriverTimingInfo driverTimingInfo, CultureInfo culture) { if (driverTimingInfo.GeneratorTimes.IsEmpty)