mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Update NuGet packages
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.25.0" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.1" PrivateAssets="all" />
|
||||
<!-- Make sure to target the lowest possible version of the compiler for wider support -->
|
||||
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="PolyShim" Version="1.7.0" PrivateAssets="all" />
|
||||
<PackageReference Include="PolyShim" Version="1.8.0" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -55,30 +55,35 @@ internal partial class CommandOptionSymbol
|
||||
return null;
|
||||
|
||||
var name =
|
||||
attribute.ConstructorArguments
|
||||
attribute
|
||||
.ConstructorArguments
|
||||
.Where(a => a.Type?.SpecialType == SpecialType.System_String)
|
||||
.Select(a => a.Value)
|
||||
.FirstOrDefault() as string;
|
||||
|
||||
var shortName =
|
||||
attribute.ConstructorArguments
|
||||
attribute
|
||||
.ConstructorArguments
|
||||
.Where(a => a.Type?.SpecialType == SpecialType.System_Char)
|
||||
.Select(a => a.Value)
|
||||
.FirstOrDefault() as char?;
|
||||
|
||||
var isRequired =
|
||||
attribute.NamedArguments
|
||||
attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "IsRequired")
|
||||
.Select(a => a.Value.Value)
|
||||
.FirstOrDefault() as bool?;
|
||||
|
||||
var converter = attribute.NamedArguments
|
||||
var converter = attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "Converter")
|
||||
.Select(a => a.Value.Value)
|
||||
.Cast<ITypeSymbol?>()
|
||||
.FirstOrDefault();
|
||||
|
||||
var validators = attribute.NamedArguments
|
||||
var validators = attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "Validators")
|
||||
.SelectMany(a => a.Value.Values)
|
||||
.Select(c => c.Value)
|
||||
|
||||
@@ -57,24 +57,28 @@ internal partial class CommandParameterSymbol
|
||||
var order = (int)attribute.ConstructorArguments.Select(a => a.Value).First()!;
|
||||
|
||||
var name =
|
||||
attribute.NamedArguments
|
||||
attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "Name")
|
||||
.Select(a => a.Value.Value)
|
||||
.FirstOrDefault() as string;
|
||||
|
||||
var isRequired =
|
||||
attribute.NamedArguments
|
||||
attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "IsRequired")
|
||||
.Select(a => a.Value.Value)
|
||||
.FirstOrDefault() as bool?;
|
||||
|
||||
var converter = attribute.NamedArguments
|
||||
var converter = attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "Converter")
|
||||
.Select(a => a.Value.Value)
|
||||
.Cast<ITypeSymbol?>()
|
||||
.FirstOrDefault();
|
||||
|
||||
var validators = attribute.NamedArguments
|
||||
var validators = attribute
|
||||
.NamedArguments
|
||||
.Where(a => a.Key == "Validators")
|
||||
.SelectMany(a => a.Value.Values)
|
||||
.Select(c => c.Value)
|
||||
|
||||
@@ -31,9 +31,10 @@ public class OptionMustBeInsideCommandAnalyzer : AnalyzerBase
|
||||
if (!CommandOptionSymbol.IsOptionProperty(property))
|
||||
return;
|
||||
|
||||
var isInsideCommand = property.ContainingType.AllInterfaces.Any(
|
||||
i => i.DisplayNameMatches(SymbolNames.CliFxCommandInterface)
|
||||
);
|
||||
var isInsideCommand = property
|
||||
.ContainingType
|
||||
.AllInterfaces
|
||||
.Any(i => i.DisplayNameMatches(SymbolNames.CliFxCommandInterface));
|
||||
|
||||
if (!isInsideCommand)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,8 @@ public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
if (string.IsNullOrWhiteSpace(option.Name))
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -34,7 +34,8 @@ public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase
|
||||
if (option.ShortName is null)
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -29,12 +29,14 @@ public class OptionMustHaveValidConverterAnalyzer : AnalyzerBase
|
||||
if (option.ConverterType is null)
|
||||
return;
|
||||
|
||||
var converterValueType = option.ConverterType
|
||||
var converterValueType = option
|
||||
.ConverterType
|
||||
.GetBaseTypes()
|
||||
.FirstOrDefault(
|
||||
t => t.ConstructedFrom.DisplayNameMatches(SymbolNames.CliFxBindingConverterClass)
|
||||
)
|
||||
?.TypeArguments.FirstOrDefault();
|
||||
?.TypeArguments
|
||||
.FirstOrDefault();
|
||||
|
||||
// Value returned by the converter must be assignable to the property type
|
||||
var isCompatible =
|
||||
@@ -45,10 +47,9 @@ public class OptionMustHaveValidConverterAnalyzer : AnalyzerBase
|
||||
? context.Compilation.IsAssignable(converterValueType, property.Type)
|
||||
// Non-scalar (assume we can handle all IEnumerable types for simplicity)
|
||||
: property.Type.TryGetEnumerableUnderlyingType() is { } enumerableUnderlyingType
|
||||
&& context.Compilation.IsAssignable(
|
||||
converterValueType,
|
||||
enumerableUnderlyingType
|
||||
)
|
||||
&& context
|
||||
.Compilation
|
||||
.IsAssignable(converterValueType, enumerableUnderlyingType)
|
||||
);
|
||||
|
||||
if (!isCompatible)
|
||||
|
||||
@@ -34,7 +34,8 @@ public class OptionMustHaveValidValidatorsAnalyzer : AnalyzerBase
|
||||
t =>
|
||||
t.ConstructedFrom.DisplayNameMatches(SymbolNames.CliFxBindingValidatorClass)
|
||||
)
|
||||
?.TypeArguments.FirstOrDefault();
|
||||
?.TypeArguments
|
||||
.FirstOrDefault();
|
||||
|
||||
// Value passed to the validator must be assignable from the property type
|
||||
var isCompatible =
|
||||
|
||||
@@ -31,9 +31,10 @@ public class ParameterMustBeInsideCommandAnalyzer : AnalyzerBase
|
||||
if (!CommandParameterSymbol.IsParameterProperty(property))
|
||||
return;
|
||||
|
||||
var isInsideCommand = property.ContainingType.AllInterfaces.Any(
|
||||
i => i.DisplayNameMatches(SymbolNames.CliFxCommandInterface)
|
||||
);
|
||||
var isInsideCommand = property
|
||||
.ContainingType
|
||||
.AllInterfaces
|
||||
.Any(i => i.DisplayNameMatches(SymbolNames.CliFxCommandInterface));
|
||||
|
||||
if (!isInsideCommand)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,8 @@ public class ParameterMustBeLastIfNonRequiredAnalyzer : AnalyzerBase
|
||||
if (parameter.IsRequired != false)
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -33,7 +33,8 @@ public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase
|
||||
if (parameter.IsScalar())
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -33,7 +33,8 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzer : AnalyzerBase
|
||||
if (parameter.IsRequired != false)
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -33,7 +33,8 @@ public class ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase
|
||||
if (parameter.IsScalar())
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -35,7 +35,8 @@ public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase
|
||||
if (string.IsNullOrWhiteSpace(parameter.Name))
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -31,7 +31,8 @@ public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase
|
||||
if (parameter is null)
|
||||
return;
|
||||
|
||||
var otherProperties = property.ContainingType
|
||||
var otherProperties = property
|
||||
.ContainingType
|
||||
.GetMembers()
|
||||
.OfType<IPropertySymbol>()
|
||||
.Where(m => !m.Equals(property))
|
||||
|
||||
@@ -29,12 +29,14 @@ public class ParameterMustHaveValidConverterAnalyzer : AnalyzerBase
|
||||
if (parameter.ConverterType is null)
|
||||
return;
|
||||
|
||||
var converterValueType = parameter.ConverterType
|
||||
var converterValueType = parameter
|
||||
.ConverterType
|
||||
.GetBaseTypes()
|
||||
.FirstOrDefault(
|
||||
t => t.ConstructedFrom.DisplayNameMatches(SymbolNames.CliFxBindingConverterClass)
|
||||
)
|
||||
?.TypeArguments.FirstOrDefault();
|
||||
?.TypeArguments
|
||||
.FirstOrDefault();
|
||||
|
||||
// Value returned by the converter must be assignable to the property type
|
||||
var isCompatible =
|
||||
@@ -45,10 +47,9 @@ public class ParameterMustHaveValidConverterAnalyzer : AnalyzerBase
|
||||
? context.Compilation.IsAssignable(converterValueType, property.Type)
|
||||
// Non-scalar (assume we can handle all IEnumerable types for simplicity)
|
||||
: property.Type.TryGetEnumerableUnderlyingType() is { } enumerableUnderlyingType
|
||||
&& context.Compilation.IsAssignable(
|
||||
converterValueType,
|
||||
enumerableUnderlyingType
|
||||
)
|
||||
&& context
|
||||
.Compilation
|
||||
.IsAssignable(converterValueType, enumerableUnderlyingType)
|
||||
);
|
||||
|
||||
if (!isCompatible)
|
||||
|
||||
@@ -34,7 +34,8 @@ public class ParameterMustHaveValidValidatorsAnalyzer : AnalyzerBase
|
||||
t =>
|
||||
t.ConstructedFrom.DisplayNameMatches(SymbolNames.CliFxBindingValidatorClass)
|
||||
)
|
||||
?.TypeArguments.FirstOrDefault();
|
||||
?.TypeArguments
|
||||
.FirstOrDefault();
|
||||
|
||||
// Value passed to the validator must be assignable from the property type
|
||||
var isCompatible =
|
||||
|
||||
@@ -53,7 +53,8 @@ public class SystemConsoleShouldBeAvoidedAnalyzer : AnalyzerBase
|
||||
return;
|
||||
|
||||
// Check if IConsole is available in scope as an alternative to System.Console
|
||||
var isConsoleInterfaceAvailable = context.Node
|
||||
var isConsoleInterfaceAvailable = context
|
||||
.Node
|
||||
.Ancestors()
|
||||
.OfType<MethodDeclarationSyntax>()
|
||||
.SelectMany(m => m.ParameterList.Parameters)
|
||||
|
||||
@@ -42,9 +42,9 @@ internal static class RoslynExtensions
|
||||
// on higher versions of the C# compiler.
|
||||
public static bool IsRequired(this IPropertySymbol property) =>
|
||||
property
|
||||
// Can't rely on the RequiredMemberAttribute because it's generated by the compiler, not added by the user,
|
||||
// so we have to check for the presence of the `required` modifier in the syntax tree instead.
|
||||
.DeclaringSyntaxReferences
|
||||
// Can't rely on the RequiredMemberAttribute because it's generated by the compiler, not added by the user,
|
||||
// so we have to check for the presence of the `required` modifier in the syntax tree instead.
|
||||
.DeclaringSyntaxReferences
|
||||
.Select(r => r.GetSyntax())
|
||||
.OfType<PropertyDeclarationSyntax>()
|
||||
.SelectMany(p => p.Modifiers)
|
||||
|
||||
Reference in New Issue
Block a user