Пример #1
0
        // Analysis
        public static async Task <Diagnostic[]> AnalyzeAsync(Compilation compilation, DiagnosticAnalyzer[] analyzers, AnalyzerOptions?analyzerOptions, CancellationToken cancellationToken)
        {
            var compilationWithAnalyzers = compilation.WithAnalyzers(analyzers.ToImmutableArray(), analyzerOptions, cancellationToken);
            var diagnostics = await compilationWithAnalyzers.GetAllDiagnosticsAsync(cancellationToken).ConfigureAwait(false);

            return(diagnostics.Where(i => !IsCompilerDiagnostic(i)).OrderBy(i => i.Id).ThenBy(i => i.Location.SourceTree?.FilePath).ThenBy(i => i.Location.SourceSpan).ToArray());
        }