コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public FixMissingIgnoreReason(Document document, SyntaxNode root, TestIgnoringModel model)
 {
     _document = document;
     _root     = root;
     _model    = model;
 }