private static async Task <bool> ShouldRunAnalyzerForStateTypeAsync(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer, StateType stateTypeId, ImmutableHashSet <string> diagnosticIds = null, Func <DiagnosticAnalyzer, ImmutableArray <DiagnosticDescriptor> > getDescriptors = null) { Debug.Assert(!driver.IsAnalyzerSuppressed(analyzer)); if (diagnosticIds != null && getDescriptors(analyzer).All(d => !diagnosticIds.Contains(d.Id))) { return(false); } switch (stateTypeId) { case StateType.Syntax: return(await analyzer.SupportsSyntaxDiagnosticAnalysisAsync(driver).ConfigureAwait(false)); case StateType.Document: return(await analyzer.SupportsSemanticDiagnosticAnalysisAsync(driver).ConfigureAwait(false)); case StateType.Project: return(await analyzer.SupportsProjectDiagnosticAnalysisAsync(driver).ConfigureAwait(false)); default: throw ExceptionUtilities.Unreachable; } }
private static async Task<bool> ShouldRunAnalyzerForStateTypeAsync(DiagnosticAnalyzerDriver driver, DiagnosticAnalyzer analyzer, StateType stateTypeId, ImmutableHashSet<string> diagnosticIds = null, Func<DiagnosticAnalyzer, ImmutableArray<DiagnosticDescriptor>> getDescriptors = null) { Debug.Assert(!driver.IsAnalyzerSuppressed(analyzer)); if (diagnosticIds != null && getDescriptors(analyzer).All(d => !diagnosticIds.Contains(d.Id))) { return false; } switch (stateTypeId) { case StateType.Syntax: return await analyzer.SupportsSyntaxDiagnosticAnalysisAsync(driver).ConfigureAwait(false); case StateType.Document: return await analyzer.SupportsSemanticDiagnosticAnalysisAsync(driver).ConfigureAwait(false); case StateType.Project: return await analyzer.SupportsProjectDiagnosticAnalysisAsync(driver).ConfigureAwait(false); default: throw ExceptionUtilities.Unreachable; } }