public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            if (!TryFindFirstAncestorOrSelf(root, context.Span, out ArgumentListSyntax argumentList))
            {
                return;
            }

            CodeAction codeAction = CodeAction.Create(
                "Remove empty argument list",
                cancellationToken => RemoveEmptyArgumentListRefactoring.RefactorAsync(context.Document, argumentList, cancellationToken),
                GetEquivalenceKey(DiagnosticIdentifiers.RemoveEmptyArgumentList));

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }
Пример #2
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            ArgumentListSyntax argumentList = root
                                              .FindNode(context.Span, getInnermostNodeForTie: true)?
                                              .FirstAncestorOrSelf <ArgumentListSyntax>();

            if (argumentList == null)
            {
                return;
            }

            CodeAction codeAction = CodeAction.Create(
                "Remove empty argument list",
                cancellationToken => RemoveEmptyArgumentListRefactoring.RefactorAsync(context.Document, argumentList, cancellationToken),
                DiagnosticIdentifiers.RemoveEmptyArgumentList + EquivalenceKeySuffix);

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }