public static Diagnostic ApplySourceSuppressions(Diagnostic diagnostic, Compilation compilation, ISymbol symbolOpt = null) { if (diagnostic.IsSuppressed) { // Diagnostic already has a source suppression. return(diagnostic); } var suppressMessageState = AnalyzerDriver.GetOrCreateCachedCompilationData(compilation).SuppressMessageAttributeState; SuppressMessageInfo info; if (suppressMessageState.IsDiagnosticSuppressed(diagnostic, out info)) { // Attach the suppression info to the diagnostic. diagnostic = diagnostic.WithIsSuppressed(true); } return(diagnostic); }
private static bool IsDiagnosticSuppressed(Diagnostic diagnostic, Compilation compilation, out SuppressMessageInfo info) { var suppressMessageState = AnalyzerDriver.GetOrCreateCachedCompilationData(compilation).SuppressMessageAttributeState; return(suppressMessageState.IsDiagnosticSuppressed(diagnostic, out info)); }