public static void WriteUsedFixers( ImmutableArray <CodeFixProvider> fixers, CodeAnalysisOptions options, ConsoleColors colors, Verbosity verbosity) { if (!ShouldWrite(verbosity)) { return; } foreach (IGrouping <string, string> grouping in fixers .SelectMany(f => f.FixableDiagnosticIds) .Distinct() .Where(f => options.IsSupportedDiagnosticId(f)) .GroupBy(f => f, DiagnosticIdComparer.Prefix) .OrderBy(f => f.Key, DiagnosticIdComparer.Prefix)) { int count = grouping.Count(); string prefix = DiagnosticIdPrefix.GetPrefix(grouping.Key); Write($" {count} fixable {((count == 1) ? "diagnostic" : "diagnostics")} with ", colors, verbosity); Write((string.IsNullOrEmpty(prefix)) ? "no prefix" : $"prefix '{prefix}'", colors, verbosity); using (IEnumerator <string> en = grouping .OrderBy(f => f) .GetEnumerator()) { if (en.MoveNext()) { Write(" (", colors, verbosity); while (true) { Write(en.Current, colors, verbosity); if (en.MoveNext()) { Write(", ", colors, verbosity); } else { break; } } Write(")", colors, verbosity); } } WriteLine("", colors, verbosity); } }
public static void WriteUsedAnalyzers( ImmutableArray <DiagnosticAnalyzer> analyzers, Func <DiagnosticDescriptor, bool> predicate, CodeAnalysisOptions options, ConsoleColor color, Verbosity verbosity) { if (!analyzers.Any()) { return; } if (!ShouldWrite(verbosity)) { return; } IEnumerable <DiagnosticDescriptor> descriptors = analyzers .SelectMany(f => f.SupportedDiagnostics) .Distinct(DiagnosticDescriptorComparer.Id) .Where(f => options.IsSupportedDiagnosticId(f.Id)); if (predicate != null) { descriptors = descriptors.Where(predicate); } foreach (IGrouping <DiagnosticDescriptor, DiagnosticDescriptor> grouping in descriptors .OrderBy(f => f.Id) .GroupBy(f => f, DiagnosticDescriptorComparer.IdPrefix)) { int count = grouping.Count(); string prefix = DiagnosticIdPrefix.GetPrefix(grouping.Key.Id); Write($" {count} supported {((count == 1) ? "diagnostic" : "diagnostics")} with prefix '{prefix}'", color, verbosity); using (IEnumerator <DiagnosticDescriptor> en = grouping.GetEnumerator()) { if (en.MoveNext()) { Write(" (", color, verbosity); while (true) { Write(en.Current.Id, color, verbosity); if (en.MoveNext()) { Write(", ", color, verbosity); } else { break; } } Write(")", color, verbosity); } } WriteLine("", color, verbosity); } }