public static void WriteUsedFixers( ImmutableArray <CodeFixProvider> fixers, CodeAnalysisOptions options, ConsoleColor color, 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 ", color, verbosity); Write((string.IsNullOrEmpty(prefix)) ? "no prefix" : $"prefix '{prefix}'", color, verbosity); using (IEnumerator <string> en = grouping .OrderBy(f => f) .GetEnumerator()) { if (en.MoveNext()) { Write(" (", color, verbosity); while (true) { Write(en.Current, color, verbosity); if (en.MoveNext()) { Write(", ", color, verbosity); } else { break; } } Write(")", color, verbosity); } } WriteLine("", color, 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); } }