public async Task <IEnumerable <Diagnostic> > GetProjectDiagnosticsAsync(DiagnosticAnalyzer analyzer, Action <Project, DiagnosticAnalyzer, CancellationToken> forceAnalyzeAllDocuments) { Contract.ThrowIfNull(this.project); Contract.ThrowIfFalse(this.document == null); Contract.ThrowIfFalse(analyzer.SupportsProjectDiagnosticAnalysis(this)); using (var diagnostics = SharedPools.Default <List <Diagnostic> >().GetPooledObject()) { if (this.project.SupportsCompilation) { await this.GetCompilationDiagnosticsAsync(analyzer, diagnostics.Object, forceAnalyzeAllDocuments).ConfigureAwait(false); } await this.GetProjectDiagnosticsWorkerAsync(analyzer, diagnostics.Object).ConfigureAwait(false); return(diagnostics.Object.ToImmutableArray()); } }
private static bool ShouldRunProviderForStateType(StateType stateTypeId, DiagnosticAnalyzer provider, DiagnosticAnalyzerDriver driver, out bool supportsSemanticInSpan, ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptor = null) { Debug.Assert(!IsAnalyzerSuppressed(provider, driver.Project.CompilationOptions, driver)); supportsSemanticInSpan = false; if (diagnosticIds != null && getDescriptor(provider).All(d => !diagnosticIds.Contains(d.Id))) { return false; } switch (stateTypeId) { case StateType.Syntax: return provider.SupportsSyntaxDiagnosticAnalysis(driver); case StateType.Document: return provider.SupportsSemanticDiagnosticAnalysis(driver, out supportsSemanticInSpan); case StateType.Project: return provider.SupportsProjectDiagnosticAnalysis(driver); default: throw ExceptionUtilities.Unreachable; } }
public async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(DiagnosticAnalyzer analyzer, Action<Project, DiagnosticAnalyzer, CancellationToken> forceAnalyzeAllDocuments) { Contract.ThrowIfNull(_project); Contract.ThrowIfFalse(_document == null); Contract.ThrowIfFalse(analyzer.SupportsProjectDiagnosticAnalysis(this)); using (var diagnostics = SharedPools.Default<List<Diagnostic>>().GetPooledObject()) { if (_project.SupportsCompilation) { await this.GetCompilationDiagnosticsAsync(analyzer, diagnostics.Object, forceAnalyzeAllDocuments).ConfigureAwait(false); } await this.GetProjectDiagnosticsWorkerAsync(analyzer, diagnostics.Object).ConfigureAwait(false); return diagnostics.Object.ToImmutableArray(); } }