/// <summary> /// Returns true if the given symbol has been configured to be excluded from analysis by options. /// </summary> public static bool IsConfiguredToSkipAnalysis( this ISymbol symbol, AnalyzerOptions options, DiagnosticDescriptor rule, Compilation compilation, CancellationToken cancellationToken) { var excludedSymbols = options.GetExcludedSymbolNamesOption(rule, compilation, cancellationToken); var excludedTypeNamesWithDerivedTypes = options.GetExcludedTypeNamesWithDerivedTypesOption(rule, compilation, cancellationToken); if (excludedSymbols.IsEmpty && excludedTypeNamesWithDerivedTypes.IsEmpty) { return(false); } while (symbol != null) { if (excludedSymbols.Contains(symbol)) { return(true); } if (symbol is INamedTypeSymbol namedType && !excludedTypeNamesWithDerivedTypes.IsEmpty) { foreach (var type in namedType.GetBaseTypesAndThis()) { if (excludedTypeNamesWithDerivedTypes.Contains(type)) { return(true); } } } symbol = symbol.ContainingSymbol; } return(false); }