Example #1
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            PrefixUnaryExpressionSyntax node = await context.FindNodeAsync <PrefixUnaryExpressionSyntax>(getInnermostNodeForTie : true).ConfigureAwait(false);

            CodeAction codeAction = CodeAction.Create(
                "Simplify '!' expression",
                cancellationToken => RefactorAsync(context.Document, node, cancellationToken),
                DiagnosticIdentifiers.SimplifyLogicalNotExpression + EquivalenceKeySuffix);

            context.RegisterCodeFix(codeAction, context.Diagnostics);
        }
Example #2
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            ParenthesizedExpressionSyntax parenthesizedExpression = await context
                                                                    .FindNodeAsync <ParenthesizedExpressionSyntax>(getInnermostNodeForTie : true)
                                                                    .ConfigureAwait(false);

            CodeAction codeAction = CodeAction.Create(
                "Remove redundant parentheses",
                cancellationToken => RefactorAsync(context.Document, parenthesizedExpression, cancellationToken),
                DiagnosticIdentifiers.RemoveRedundantParentheses + EquivalenceKeySuffix);

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