Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -102,6 +102,13 @@ private static void ReportAnalyzerExecutionTime(TextWriter consoleOutput, Analyz
}
}

private static IEnumerable<string> 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)
Expand Down