diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 071a75bd..43c59145 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,10 +21,6 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 5.0.301 - 6.0.101 - name: Setup Node.js uses: actions/setup-node@v3 @@ -80,10 +76,6 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 5.0.301 - 6.0.101 - name: Integration Tests shell: bash diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index d15f3cf1..ffa42e80 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -43,10 +43,6 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 5.0.301 - 6.0.101 - name: Build shell: bash @@ -70,10 +66,6 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 5.0.301 - 6.0.101 - name: Setup Node.js uses: actions/setup-node@v3 @@ -115,10 +107,6 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v2 - with: - dotnet-version: | - 5.0.301 - 6.0.101 - name: Publish shell: bash diff --git a/docs/global.json b/docs/global.json index 6ecdd616..49d22552 100644 --- a/docs/global.json +++ b/docs/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.101", + "version": "6.0.300", "rollForward": "latestFeature" } } diff --git a/examples/Cli/Injection/Injection.csproj b/examples/Cli/Injection/Injection.csproj index 18f57020..9d9db396 100644 --- a/examples/Cli/Injection/Injection.csproj +++ b/examples/Cli/Injection/Injection.csproj @@ -11,7 +11,7 @@ - + diff --git a/examples/Cli/Logging/Logging.csproj b/examples/Cli/Logging/Logging.csproj index e54e1d7d..e7c4cd02 100644 --- a/examples/Cli/Logging/Logging.csproj +++ b/examples/Cli/Logging/Logging.csproj @@ -12,10 +12,10 @@ - - - - + + + + diff --git a/examples/Console/Progress/Progress.csproj b/examples/Console/Progress/Progress.csproj index a5942b58..06a9a287 100644 --- a/examples/Console/Progress/Progress.csproj +++ b/examples/Console/Progress/Progress.csproj @@ -9,7 +9,7 @@ - + diff --git a/examples/Console/Status/Status.csproj b/examples/Console/Status/Status.csproj index 55db6c90..96a7472c 100644 --- a/examples/Console/Status/Status.csproj +++ b/examples/Console/Status/Status.csproj @@ -9,7 +9,7 @@ - + diff --git a/global.json b/global.json index 6a1b5cef..d00cb919 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "projects": [ "src", "tests" ], "sdk": { - "version": "6.0.101", + "version": "6.0.300", "rollForward": "latestFeature" } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 114901bc..64057c44 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -32,12 +32,12 @@ - + - + All - + All diff --git a/src/Spectre.Console.Analyzer.Sandbox/Spectre.Console.Analyzer.Sandbox.csproj b/src/Spectre.Console.Analyzer.Sandbox/Spectre.Console.Analyzer.Sandbox.csproj index a6c93fdc..3f799ca9 100644 --- a/src/Spectre.Console.Analyzer.Sandbox/Spectre.Console.Analyzer.Sandbox.csproj +++ b/src/Spectre.Console.Analyzer.Sandbox/Spectre.Console.Analyzer.Sandbox.csproj @@ -1,8 +1,8 @@ - + Exe - net5.0 + net6.0 diff --git a/src/Spectre.Console.Analyzer.v3.ncrunchsolution b/src/Spectre.Console.Analyzer.v3.ncrunchsolution new file mode 100644 index 00000000..10420ac9 --- /dev/null +++ b/src/Spectre.Console.Analyzer.v3.ncrunchsolution @@ -0,0 +1,6 @@ + + + True + True + + \ No newline at end of file diff --git a/src/Spectre.Console.Analyzer/Analyzers/FavorInstanceAnsiConsoleOverStaticAnalyzer.cs b/src/Spectre.Console.Analyzer/Analyzers/FavorInstanceAnsiConsoleOverStaticAnalyzer.cs index bd9bb286..eb641797 100644 --- a/src/Spectre.Console.Analyzer/Analyzers/FavorInstanceAnsiConsoleOverStaticAnalyzer.cs +++ b/src/Spectre.Console.Analyzer/Analyzers/FavorInstanceAnsiConsoleOverStaticAnalyzer.cs @@ -24,7 +24,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer // if this operation isn't an invocation against one of the System.Console methods // defined in _methods then we can safely stop analyzing and return; var invocationOperation = (IInvocationOperation)context.Operation; - if (!Equals(invocationOperation.TargetMethod.ContainingType, ansiConsoleType)) + if (!SymbolEqualityComparer.Default.Equals(invocationOperation.TargetMethod.ContainingType, ansiConsoleType)) { return; } @@ -63,7 +63,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer .Ancestors().OfType() .First() .ParameterList.Parameters - .Any(i => i.Type.NormalizeWhitespace().ToString() == "IAnsiConsole"); + .Any(i => i.Type?.NormalizeWhitespace()?.ToString() == "IAnsiConsole"); } private static bool HasFieldAnsiConsole(SyntaxNode syntaxNode) @@ -72,7 +72,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer .Ancestors() .OfType() .First() - .Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword); + .Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword)); return syntaxNode .Ancestors().OfType() @@ -81,6 +81,6 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer .OfType() .Any(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)))); } } \ No newline at end of file diff --git a/src/Spectre.Console.Analyzer/Analyzers/NoConcurrentLiveRenderablesAnalyzer.cs b/src/Spectre.Console.Analyzer/Analyzers/NoConcurrentLiveRenderablesAnalyzer.cs index 9aa59d4c..4565b64d 100644 --- a/src/Spectre.Console.Analyzer/Analyzers/NoConcurrentLiveRenderablesAnalyzer.cs +++ b/src/Spectre.Console.Analyzer/Analyzers/NoConcurrentLiveRenderablesAnalyzer.cs @@ -33,12 +33,14 @@ public class NoConcurrentLiveRenderablesAnalyzer : SpectreAnalyzer .Select(i => context.Compilation.GetTypeByMetadataName(i)) .ToImmutableArray(); - if (liveTypes.All(i => !Equals(i, methodSymbol.ContainingType))) + if (liveTypes.All(i => !SymbolEqualityComparer.Default.Equals(i, methodSymbol.ContainingType))) { return; } +#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var model = context.Compilation.GetSemanticModel(context.Operation.Syntax.SyntaxTree); +#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var parentInvocations = invocationOperation .Syntax.Ancestors() .OfType() diff --git a/src/Spectre.Console.Analyzer/Analyzers/NoPromptsDuringLiveRenderablesAnalyzer.cs b/src/Spectre.Console.Analyzer/Analyzers/NoPromptsDuringLiveRenderablesAnalyzer.cs index 8e87ef99..ba47b2f9 100644 --- a/src/Spectre.Console.Analyzer/Analyzers/NoPromptsDuringLiveRenderablesAnalyzer.cs +++ b/src/Spectre.Console.Analyzer/Analyzers/NoPromptsDuringLiveRenderablesAnalyzer.cs @@ -34,12 +34,15 @@ public class NoPromptsDuringLiveRenderablesAnalyzer : SpectreAnalyzer var ansiConsoleType = context.Compilation.GetTypeByMetadataName("Spectre.Console.AnsiConsole"); var ansiConsoleExtensionsType = context.Compilation.GetTypeByMetadataName("Spectre.Console.AnsiConsoleExtensions"); - if (!Equals(methodSymbol.ContainingType, ansiConsoleType) && !Equals(methodSymbol.ContainingType, ansiConsoleExtensionsType)) + if (!SymbolEqualityComparer.Default.Equals(methodSymbol.ContainingType, ansiConsoleType) && + !SymbolEqualityComparer.Default.Equals(methodSymbol.ContainingType, ansiConsoleExtensionsType)) { return; } +#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var model = context.Compilation.GetSemanticModel(context.Operation.Syntax.SyntaxTree); +#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer var parentInvocations = invocationOperation .Syntax.Ancestors() .OfType() diff --git a/src/Spectre.Console.Analyzer/Analyzers/UseSpectreInsteadOfSystemConsoleAnalyzer.cs b/src/Spectre.Console.Analyzer/Analyzers/UseSpectreInsteadOfSystemConsoleAnalyzer.cs index 3c91f1d2..3836a321 100644 --- a/src/Spectre.Console.Analyzer/Analyzers/UseSpectreInsteadOfSystemConsoleAnalyzer.cs +++ b/src/Spectre.Console.Analyzer/Analyzers/UseSpectreInsteadOfSystemConsoleAnalyzer.cs @@ -33,7 +33,7 @@ public class UseSpectreInsteadOfSystemConsoleAnalyzer : SpectreAnalyzer var systemConsoleType = context.Compilation.GetTypeByMetadataName("System.Console"); - if (!Equals(invocationOperation.TargetMethod.ContainingType, systemConsoleType)) + if (!SymbolEqualityComparer.Default.Equals(invocationOperation.TargetMethod.ContainingType, systemConsoleType)) { return; } diff --git a/src/Spectre.Console.Analyzer/Fixes/CodeActions/SwitchToAnsiConsoleAction.cs b/src/Spectre.Console.Analyzer/Fixes/CodeActions/SwitchToAnsiConsoleAction.cs index f4421efd..11a1e17d 100644 --- a/src/Spectre.Console.Analyzer/Fixes/CodeActions/SwitchToAnsiConsoleAction.cs +++ b/src/Spectre.Console.Analyzer/Fixes/CodeActions/SwitchToAnsiConsoleAction.cs @@ -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() .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() .First() - .Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword); + .Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword)); return _originalInvocation .Ancestors().OfType() @@ -88,7 +93,7 @@ public class SwitchToAnsiConsoleAction : CodeAction .OfType() .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; } diff --git a/src/Spectre.Console.Analyzer/Fixes/FixProviders/StaticAnsiConsoleToInstanceFix.cs b/src/Spectre.Console.Analyzer/Fixes/FixProviders/StaticAnsiConsoleToInstanceFix.cs index 3a737481..dfed1f3a 100644 --- a/src/Spectre.Console.Analyzer/Fixes/FixProviders/StaticAnsiConsoleToInstanceFix.cs +++ b/src/Spectre.Console.Analyzer/Fixes/FixProviders/StaticAnsiConsoleToInstanceFix.cs @@ -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(); - 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(); + if (methodDeclaration != null) + { + context.RegisterCodeFix( + new SwitchToAnsiConsoleAction( + context.Document, + methodDeclaration, + "Convert static AnsiConsole calls to local instance."), + context.Diagnostics); + } + } } } \ No newline at end of file diff --git a/src/Spectre.Console.Analyzer/Fixes/FixProviders/SystemConsoleToAnsiConsoleFix.cs b/src/Spectre.Console.Analyzer/Fixes/FixProviders/SystemConsoleToAnsiConsoleFix.cs index eeee8884..a90d99da 100644 --- a/src/Spectre.Console.Analyzer/Fixes/FixProviders/SystemConsoleToAnsiConsoleFix.cs +++ b/src/Spectre.Console.Analyzer/Fixes/FixProviders/SystemConsoleToAnsiConsoleFix.cs @@ -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(); - 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(); + if (methodDeclaration != null) + { + context.RegisterCodeFix( + new SwitchToAnsiConsoleAction( + context.Document, + methodDeclaration, + "Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"), + context.Diagnostics); + } + } } } \ No newline at end of file diff --git a/src/Spectre.Console.Analyzer/Spectre.Console.Analyzer.csproj b/src/Spectre.Console.Analyzer/Spectre.Console.Analyzer.csproj index e97d0948..39b91872 100644 --- a/src/Spectre.Console.Analyzer/Spectre.Console.Analyzer.csproj +++ b/src/Spectre.Console.Analyzer/Spectre.Console.Analyzer.csproj @@ -1,4 +1,4 @@ - + Best practice analyzers for Spectre.Console. @@ -15,9 +15,10 @@ - - - + + + + diff --git a/src/Spectre.Console.Cli/Spectre.Console.Cli.csproj b/src/Spectre.Console.Cli/Spectre.Console.Cli.csproj index 881d7cb7..42fe9224 100644 --- a/src/Spectre.Console.Cli/Spectre.Console.Cli.csproj +++ b/src/Spectre.Console.Cli/Spectre.Console.Cli.csproj @@ -1,7 +1,7 @@ - net6.0;net5.0;netstandard2.0 + net6.0;netstandard2.0 enable true SA1633 diff --git a/src/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj b/src/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj index e15af2b7..5564af28 100644 --- a/src/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj +++ b/src/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj @@ -1,7 +1,7 @@ - net6.0;net5.0;netstandard2.0 + net6.0;netstandard2.0 enable true A library that extends Spectre.Console with ImageSharp superpowers. @@ -13,7 +13,7 @@ - + diff --git a/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj b/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj index c81ef036..851b890d 100644 --- a/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj +++ b/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj @@ -1,7 +1,7 @@ - net6.0;net5.0;netstandard2.0 + net6.0;netstandard2.0 false enable true diff --git a/src/Spectre.Console/Spectre.Console.csproj b/src/Spectre.Console/Spectre.Console.csproj index f12db118..034f2928 100644 --- a/src/Spectre.Console/Spectre.Console.csproj +++ b/src/Spectre.Console/Spectre.Console.csproj @@ -1,14 +1,14 @@ - net6.0;net5.0;netstandard2.0 + net6.0;netstandard2.0 enable true SA1633 - + @@ -20,6 +20,7 @@ + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index c6403bbd..88ea5450 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -6,10 +6,10 @@ - + All - + All diff --git a/test/Spectre.Console.Analyzer.Tests/CodeAnalyzerHelper.cs b/test/Spectre.Console.Analyzer.Tests/CodeAnalyzerHelper.cs index 43129950..860fcc88 100644 --- a/test/Spectre.Console.Analyzer.Tests/CodeAnalyzerHelper.cs +++ b/test/Spectre.Console.Analyzer.Tests/CodeAnalyzerHelper.cs @@ -6,7 +6,7 @@ internal static class CodeAnalyzerHelper static CodeAnalyzerHelper() { - CurrentSpectre = ReferenceAssemblies.Net.Net50.AddAssemblies( + CurrentSpectre = ReferenceAssemblies.Net.Net60.AddAssemblies( ImmutableArray.Create(typeof(AnsiConsole).Assembly.Location.Replace(".dll", string.Empty))); } } diff --git a/test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj b/test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj index 3e1881a0..e66b1800 100644 --- a/test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj +++ b/test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 false @@ -10,12 +10,12 @@ - - - - + + + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Spectre.Console.Analyzer.Tests/SpectreAnalyzerVerifier.cs b/test/Spectre.Console.Analyzer.Tests/SpectreAnalyzerVerifier.cs index 91c503d1..8aadab6a 100644 --- a/test/Spectre.Console.Analyzer.Tests/SpectreAnalyzerVerifier.cs +++ b/test/Spectre.Console.Analyzer.Tests/SpectreAnalyzerVerifier.cs @@ -8,14 +8,6 @@ public static class SpectreAnalyzerVerifier private static Task VerifyCodeFixAsync(string source, IEnumerable expected, string fixedSource) { - // Roslyn fixers always use \r\n for newlines, regardless of OS environment settings, so we normalize - // the source as it typically comes from multi-line strings with varying newlines. - if (Environment.NewLine != "\r\n") - { - source = source.Replace(Environment.NewLine, "\r\n"); - fixedSource = fixedSource.Replace(Environment.NewLine, "\r\n"); - } - var test = new Test { TestCode = source, diff --git a/test/Spectre.Console.Cli.Tests/Properties/Usings.cs b/test/Spectre.Console.Cli.Tests/Properties/Usings.cs index 41d63b89..be00c044 100644 --- a/test/Spectre.Console.Cli.Tests/Properties/Usings.cs +++ b/test/Spectre.Console.Cli.Tests/Properties/Usings.cs @@ -11,7 +11,6 @@ global using Spectre.Console.Cli; global using Spectre.Console.Cli.Unsafe; global using Spectre.Console.Testing; global using Spectre.Console.Tests.Data; -global using Spectre.Verify.Extensions; global using VerifyTests; global using VerifyXunit; global using Xunit; \ No newline at end of file diff --git a/test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj b/test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj index c9c33c73..68a74c82 100644 --- a/test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj +++ b/test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj @@ -1,8 +1,8 @@ - net6.0;net5.0;net48 - net6.0;net5.0 + net6.0;net48 + net6.0 @@ -10,16 +10,16 @@ - + - + - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Spectre.Console.Tests/Properties/Usings.cs b/test/Spectre.Console.Tests/Properties/Usings.cs index 95304aff..cd79736a 100644 --- a/test/Spectre.Console.Tests/Properties/Usings.cs +++ b/test/Spectre.Console.Tests/Properties/Usings.cs @@ -13,7 +13,6 @@ global using Spectre.Console.Advanced; global using Spectre.Console.Rendering; global using Spectre.Console.Testing; global using Spectre.Console.Tests.Data; -global using Spectre.Verify.Extensions; global using VerifyTests; global using VerifyXunit; global using Xunit; \ No newline at end of file diff --git a/test/Spectre.Console.Tests/Spectre.Console.Tests.csproj b/test/Spectre.Console.Tests/Spectre.Console.Tests.csproj index cd498d7f..ea2c3fae 100644 --- a/test/Spectre.Console.Tests/Spectre.Console.Tests.csproj +++ b/test/Spectre.Console.Tests/Spectre.Console.Tests.csproj @@ -1,8 +1,8 @@ - net6.0;net5.0;net48 - net6.0;net5.0 + net6.0;net48 + net6.0 @@ -12,16 +12,16 @@ - + - + - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -33,9 +33,4 @@ - - - - -