Allow to apply code fix in top-level statements

This commit is contained in:
Gérald Barré
2023-02-19 15:03:45 -05:00
committed by Phil Scott
parent 819b948e78
commit 955fe07bac
4 changed files with 45 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ public class StaticAnsiConsoleToInstanceFix : CodeFixProvider
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
if (root != null)
{
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
var methodDeclaration = root.FindNode(context.Span, getInnermostNodeForTie: true).FirstAncestorOrSelf<InvocationExpressionSyntax>();
if (methodDeclaration != null)
{
context.RegisterCodeFix(