public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { var document = context.Document; var root = await document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); var attributeSyntax = root.FindNode(context.Span).FirstAncestorOrSelf <AttributeSyntax>(); var model = new TestIgnoringModel(attributeSyntax); context.RegisterCodeFix(new FixMissingIgnoreReason(document, root, model), context.Diagnostics); }
protected override void Analyze(SyntaxNodeAnalysisContext context, AttributeSyntax attributeSyntax) { var ignoringModel = new TestIgnoringModel(attributeSyntax); if (!ignoringModel.DoesIgnoringNeedAdjustment) { return; } var attributeLocation = attributeSyntax.GetLocation(); var reportMessage = ignoringModel.ReportMessage; context.ReportDiagnostic(Diagnostic.Create(Descriptors.IgnoreReason, attributeLocation, reportMessage)); }
public FixMissingIgnoreReason(Document document, SyntaxNode root, TestIgnoringModel model) { _document = document; _root = root; _model = model; }