public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false); if (!TryFindFirstAncestorOrSelf(root, context.Span, out BaseTypeSyntax baseType)) { return; } CodeAction codeAction = CodeAction.Create( "Remove redundant base interface", cancellationToken => RemoveRedundantBaseInterfaceRefactoring.RefactorAsync(context.Document, baseType, cancellationToken), GetEquivalenceKey(DiagnosticIdentifiers.RemoveRedundantBaseInterface)); context.RegisterCodeFix(codeAction, context.Diagnostics); }
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false); BaseTypeSyntax baseType = root .FindNode(context.Span, getInnermostNodeForTie: true)? .FirstAncestorOrSelf <BaseTypeSyntax>(); Debug.Assert(baseType != null, $"{nameof(baseType)} is null"); if (baseType == null) { return; } CodeAction codeAction = CodeAction.Create( "Remove redundant base interface", cancellationToken => RemoveRedundantBaseInterfaceRefactoring.RefactorAsync(context.Document, baseType, cancellationToken), DiagnosticIdentifiers.RemoveRedundantBaseInterface + EquivalenceKeySuffix); context.RegisterCodeFix(codeAction, context.Diagnostics); }