public static async Task <LatestDiagnosticsForSpanGetter> CreateAsync( DiagnosticIncrementalAnalyzer owner, Document document, TextSpan range, bool blockForData, bool includeSuppressedDiagnostics = false, string?diagnosticId = null, CancellationToken cancellationToken = default) { // REVIEW: IsAnalyzerSuppressed can be quite expensive in some cases. try to find a way to make it cheaper // Here we don't filter out hidden diagnostic only analyzer since such analyzer can produce hidden diagnostic // on active file (non local diagnostic) var stateSets = owner._stateManager .GetOrCreateStateSets(document.Project).Where(s => !owner.AnalyzerService.IsAnalyzerSuppressed(s.Analyzer, document.Project)); // filter to specific diagnostic it is looking for if (diagnosticId != null) { stateSets = stateSets.Where(s => owner.AnalyzerService.GetDiagnosticDescriptors(s.Analyzer).Any(d => d.Id == diagnosticId)).ToList(); } var compilation = await owner.CreateCompilationWithAnalyzersAsync(document.Project, stateSets, includeSuppressedDiagnostics, cancellationToken).ConfigureAwait(false); return(new LatestDiagnosticsForSpanGetter(owner, compilation, document, stateSets, diagnosticId, range, blockForData, includeSuppressedDiagnostics)); }
public static async Task <LatestDiagnosticsForSpanGetter> CreateAsync( DiagnosticIncrementalAnalyzer owner, Document document, TextSpan range, bool blockForData, bool includeSuppressedDiagnostics = false, string?diagnosticId = null, CancellationToken cancellationToken = default) { var stateSets = owner._stateManager .GetOrCreateStateSets(document.Project).Where(s => !owner.AnalyzerService.IsAnalyzerSuppressed(s.Analyzer, document.Project)); // filter to specific diagnostic it is looking for if (diagnosticId != null) { stateSets = stateSets.Where(s => owner.AnalyzerService.GetDiagnosticDescriptors(s.Analyzer).Any(d => d.Id == diagnosticId)).ToList(); } var compilation = await owner.CreateCompilationWithAnalyzersAsync(document.Project, stateSets, includeSuppressedDiagnostics, cancellationToken).ConfigureAwait(false); return(new LatestDiagnosticsForSpanGetter(owner, compilation, document, stateSets, diagnosticId, range, blockForData, includeSuppressedDiagnostics)); }