mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-06 08:12:27 +08:00
Remove the 'net50' TFM
Also updates all dependencies to the latest version. Closes #829
This commit is contained in:

committed by
Patrik Svensson

parent
b4cf7a76d3
commit
dc93edef15
@ -35,6 +35,11 @@ public class SwitchToAnsiConsoleAction : CodeAction
|
||||
var originalCaller = ((MemberAccessExpressionSyntax)_originalInvocation.Expression).Name.ToString();
|
||||
|
||||
var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (syntaxTree == null)
|
||||
{
|
||||
return _document;
|
||||
}
|
||||
|
||||
var root = (CompilationUnitSyntax)await syntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// If there is an ansiConsole passed into the method then we'll use it.
|
||||
@ -66,7 +71,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
|
||||
.Ancestors().OfType<MethodDeclarationSyntax>()
|
||||
.First()
|
||||
.ParameterList.Parameters
|
||||
.FirstOrDefault(i => i.Type.NormalizeWhitespace().ToString() == "IAnsiConsole")
|
||||
.FirstOrDefault(i => i.Type?.NormalizeWhitespace()?.ToString() == "IAnsiConsole")
|
||||
?.Identifier.Text;
|
||||
}
|
||||
|
||||
@ -79,7 +84,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
|
||||
.Ancestors()
|
||||
.OfType<MethodDeclarationSyntax>()
|
||||
.First()
|
||||
.Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword);
|
||||
.Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword));
|
||||
|
||||
return _originalInvocation
|
||||
.Ancestors().OfType<ClassDeclarationSyntax>()
|
||||
@ -88,7 +93,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
|
||||
.OfType<FieldDeclarationSyntax>()
|
||||
.FirstOrDefault(i =>
|
||||
i.Declaration.Type.NormalizeWhitespace().ToString() == "IAnsiConsole" &&
|
||||
(!isStatic ^ i.Modifiers.Any(modifier => modifier.Kind() == SyntaxKind.StaticKeyword)))
|
||||
(!isStatic ^ i.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword))))
|
||||
?.Declaration.Variables.First().Identifier.Text;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,18 @@ public class StaticAnsiConsoleToInstanceFix : CodeFixProvider
|
||||
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
|
||||
{
|
||||
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
|
||||
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
|
||||
context.RegisterCodeFix(
|
||||
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static AnsiConsole calls to local instance."),
|
||||
context.Diagnostics);
|
||||
if (root != null)
|
||||
{
|
||||
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
|
||||
if (methodDeclaration != null)
|
||||
{
|
||||
context.RegisterCodeFix(
|
||||
new SwitchToAnsiConsoleAction(
|
||||
context.Document,
|
||||
methodDeclaration,
|
||||
"Convert static AnsiConsole calls to local instance."),
|
||||
context.Diagnostics);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,9 +18,18 @@ public class SystemConsoleToAnsiConsoleFix : CodeFixProvider
|
||||
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
|
||||
{
|
||||
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
|
||||
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
|
||||
context.RegisterCodeFix(
|
||||
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
|
||||
context.Diagnostics);
|
||||
if (root != null)
|
||||
{
|
||||
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
|
||||
if (methodDeclaration != null)
|
||||
{
|
||||
context.RegisterCodeFix(
|
||||
new SwitchToAnsiConsoleAction(
|
||||
context.Document,
|
||||
methodDeclaration,
|
||||
"Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
|
||||
context.Diagnostics);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user