/// <summary> /// Get the highest possible severity for any formattable document in the project. /// </summary> public static async Task <DiagnosticSeverity> GetSeverityAsync( this DiagnosticAnalyzer analyzer, Project project, ImmutableHashSet <string> formattablePaths, CancellationToken cancellationToken) { var severity = DiagnosticSeverity.Hidden; var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); if (compilation is null) { return(severity); } foreach (var document in project.Documents) { // Is the document formattable? if (document.FilePath is null || !formattablePaths.Contains(document.FilePath)) { continue; } var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); var documentSeverity = analyzer.GetSeverity(document, project.AnalyzerOptions, options, compilation); if (documentSeverity > severity) { severity = documentSeverity; } } return(severity); }