mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-01 01:25:27 +08:00 
			
		
		
		
	Remove the 'net50' TFM
Also updates all dependencies to the latest version. Closes #829
This commit is contained in:
		 Patrik Svensson
					Patrik Svensson
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							b4cf7a76d3
						
					
				
				
					commit
					dc93edef15
				
			| @@ -32,12 +32,12 @@ | ||||
|   </PropertyGroup> | ||||
|    | ||||
|   <ItemGroup Label="Package References"> | ||||
|     <PackageReference Include="MinVer" PrivateAssets="All" Version="2.5.0" /> | ||||
|     <PackageReference Include="MinVer" PrivateAssets="All" Version="4.1.0" /> | ||||
|     <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.1.1" /> | ||||
|     <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.312"> | ||||
|     <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435"> | ||||
|       <PrivateAssets>All</PrivateAssets> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="Roslynator.Analyzers" Version="3.3.0"> | ||||
|     <PackageReference Include="Roslynator.Analyzers" Version="4.1.1"> | ||||
|       <PrivateAssets>All</PrivateAssets> | ||||
|     </PackageReference> | ||||
|   </ItemGroup> | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <OutputType>Exe</OutputType> | ||||
|     <TargetFramework>net5.0</TargetFramework> | ||||
|     <TargetFramework>net6.0</TargetFramework> | ||||
|   </PropertyGroup> | ||||
|   <ItemGroup> | ||||
|     <AdditionalFiles Include="..\stylecop.json" Link="Properties/stylecop.json" /> | ||||
|   | ||||
							
								
								
									
										6
									
								
								src/Spectre.Console.Analyzer.v3.ncrunchsolution
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/Spectre.Console.Analyzer.v3.ncrunchsolution
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| <SolutionConfiguration> | ||||
|   <Settings> | ||||
|     <AllowParallelTestExecution>True</AllowParallelTestExecution> | ||||
|     <SolutionConfigured>True</SolutionConfigured> | ||||
|   </Settings> | ||||
| </SolutionConfiguration> | ||||
| @@ -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<MethodDeclarationSyntax>() | ||||
|             .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<MethodDeclarationSyntax>() | ||||
|             .First() | ||||
|             .Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword); | ||||
|             .Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword)); | ||||
|  | ||||
|         return syntaxNode | ||||
|             .Ancestors().OfType<ClassDeclarationSyntax>() | ||||
| @@ -81,6 +81,6 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer | ||||
|             .OfType<FieldDeclarationSyntax>() | ||||
|             .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)))); | ||||
|     } | ||||
| } | ||||
| @@ -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<InvocationExpressionSyntax>() | ||||
|   | ||||
| @@ -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<InvocationExpressionSyntax>() | ||||
|   | ||||
| @@ -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; | ||||
|                 } | ||||
|   | ||||
| @@ -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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|     <PropertyGroup> | ||||
|         <Description>Best practice analyzers for Spectre.Console.</Description> | ||||
| @@ -15,9 +15,10 @@ | ||||
|     </ItemGroup> | ||||
|      | ||||
|     <ItemGroup> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="2.9.8" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.6.1" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis" Version="4.2.0" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" /> | ||||
|         <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.2.0" PrivateAssets="all" /> | ||||
|     </ItemGroup> | ||||
|      | ||||
|     <ItemGroup> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks> | ||||
|     <TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <IsPackable>true</IsPackable> | ||||
|     <NoWarn>SA1633</NoWarn> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks> | ||||
|     <TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <IsPackable>true</IsPackable> | ||||
|     <Description>A library that extends Spectre.Console with ImageSharp superpowers.</Description> | ||||
| @@ -13,7 +13,7 @@ | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="SixLabors.ImageSharp" Version="2.0.0" /> | ||||
|     <PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks> | ||||
|     <TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> | ||||
|     <IsTestProject>false</IsTestProject> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <IsPackable>true</IsPackable> | ||||
|   | ||||
| @@ -1,14 +1,14 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFrameworks>net6.0;net5.0;netstandard2.0</TargetFrameworks> | ||||
|     <TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <IsPackable>true</IsPackable> | ||||
|     <NoWarn>SA1633</NoWarn> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="System.Memory" Version="4.5.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" /> | ||||
|     <PackageReference Include="System.Memory" Version="4.5.5" Condition="'$(TargetFramework)' == 'netstandard2.0'" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
| @@ -20,6 +20,7 @@ | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="System.Memory" Version="4.5.5" /> | ||||
|     <PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" PrivateAssets="all" /> | ||||
|     <PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" /> | ||||
|     <PackageReference Include="Nullable" Version="1.3.0"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user