private static void AnalyzeDiagnostic(Diagnostic diagnostic, SuppressionAnalysisContext context) { var model = context.GetSemanticModel(diagnostic.Location.SourceTree); var methodDeclarationSyntax = context.GetSuppressibleNode <MethodDeclarationSyntax>(diagnostic); // Reuse the same detection logic regarding decorated methods with *InitializeOnLoadMethodAttribute if (InitializeOnLoadMethodAnalyzer.MethodMatches(methodDeclarationSyntax, model, out _, out _)) { context.ReportSuppression(Suppression.Create(Rule, diagnostic)); } }
private static void AnalyzeDiagnostic(Diagnostic diagnostic, SuppressionAnalysisContext context) { var sourceTree = diagnostic.Location.SourceTree; var root = sourceTree.GetRoot(context.CancellationToken); var node = root.FindNode(diagnostic.Location.SourceSpan); var model = context.GetSemanticModel(diagnostic.Location.SourceTree); // Reuse the same detection logic regarding decorated methods with *InitializeOnLoadMethodAttribute if (InitializeOnLoadMethodAnalyzer.MethodMatches(node, model, out _, out _)) { context.ReportSuppression(Suppression.Create(Rule, diagnostic)); } }