From b41e9b492962112e51b706683e12a8afa6dc80dd Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sun, 12 Nov 2023 19:08:54 +0200 Subject: [PATCH] Update NuGet packages --- .../CliFx.Analyzers.Tests.csproj | 16 ++++++------ CliFx.Analyzers.Tests/GeneralSpecs.cs | 3 ++- .../Utils/AnalyzerAssertions.cs | 16 +++++++----- CliFx.Analyzers/CliFx.Analyzers.csproj | 4 +-- .../ObjectModel/CommandOptionSymbol.cs | 15 +++++++---- .../ObjectModel/CommandParameterSymbol.cs | 12 ++++++--- .../OptionMustBeInsideCommandAnalyzer.cs | 7 +++--- .../OptionMustHaveUniqueNameAnalyzer.cs | 3 ++- .../OptionMustHaveUniqueShortNameAnalyzer.cs | 3 ++- .../OptionMustHaveValidConverterAnalyzer.cs | 13 +++++----- .../OptionMustHaveValidValidatorsAnalyzer.cs | 3 ++- .../ParameterMustBeInsideCommandAnalyzer.cs | 7 +++--- ...arameterMustBeLastIfNonRequiredAnalyzer.cs | 3 ++- .../ParameterMustBeLastIfNonScalarAnalyzer.cs | 3 ++- ...ameterMustBeSingleIfNonRequiredAnalyzer.cs | 3 ++- ...arameterMustBeSingleIfNonScalarAnalyzer.cs | 3 ++- .../ParameterMustHaveUniqueNameAnalyzer.cs | 3 ++- .../ParameterMustHaveUniqueOrderAnalyzer.cs | 3 ++- ...ParameterMustHaveValidConverterAnalyzer.cs | 13 +++++----- ...arameterMustHaveValidValidatorsAnalyzer.cs | 3 ++- .../SystemConsoleShouldBeAvoidedAnalyzer.cs | 3 ++- .../Utils/Extensions/RoslynExtensions.cs | 6 ++--- CliFx.Benchmarks/CliFx.Benchmarks.csproj | 8 +++--- CliFx.Demo/CliFx.Demo.csproj | 2 +- CliFx.Tests.Dummy/CliFx.Tests.Dummy.csproj | 2 +- CliFx.Tests/CliFx.Tests.csproj | 18 ++++++------- CliFx.Tests/Utils/DynamicCommandBuilder.cs | 7 ++++-- .../Utils/Extensions/AssertionExtensions.cs | 20 +++++++-------- CliFx/CliApplication.cs | 8 +++--- CliFx/CliFx.csproj | 4 +-- CliFx/CommandBinder.cs | 25 ++++++++++++------- CliFx/Formatting/HelpConsoleFormatter.cs | 15 ++++++----- CliFx/Schema/ApplicationSchema.cs | 7 +++--- 33 files changed, 149 insertions(+), 112 deletions(-) diff --git a/CliFx.Analyzers.Tests/CliFx.Analyzers.Tests.csproj b/CliFx.Analyzers.Tests/CliFx.Analyzers.Tests.csproj index 1ed73c5..8b6f91e 100644 --- a/CliFx.Analyzers.Tests/CliFx.Analyzers.Tests.csproj +++ b/CliFx.Analyzers.Tests/CliFx.Analyzers.Tests.csproj @@ -9,15 +9,15 @@ - + - - - - - - - + + + + + + + diff --git a/CliFx.Analyzers.Tests/GeneralSpecs.cs b/CliFx.Analyzers.Tests/GeneralSpecs.cs index 38d61b7..1fc1d40 100644 --- a/CliFx.Analyzers.Tests/GeneralSpecs.cs +++ b/CliFx.Analyzers.Tests/GeneralSpecs.cs @@ -12,7 +12,8 @@ public class GeneralSpecs public void All_analyzers_have_unique_diagnostic_IDs() { // Arrange - var analyzers = typeof(AnalyzerBase).Assembly + var analyzers = typeof(AnalyzerBase) + .Assembly .GetTypes() .Where(t => !t.IsAbstract && t.IsAssignableTo(typeof(DiagnosticAnalyzer))) .Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t)!) diff --git a/CliFx.Analyzers.Tests/Utils/AnalyzerAssertions.cs b/CliFx.Analyzers.Tests/Utils/AnalyzerAssertions.cs index 1fb1ef6..b4d5906 100644 --- a/CliFx.Analyzers.Tests/Utils/AnalyzerAssertions.cs +++ b/CliFx.Analyzers.Tests/Utils/AnalyzerAssertions.cs @@ -31,7 +31,8 @@ internal class AnalyzerAssertions : ReferenceTypeAssertions t.IsPublic) .Select(t => t.Namespace) @@ -55,9 +56,10 @@ internal class AnalyzerAssertions : ReferenceTypeAssertions { @@ -148,7 +151,8 @@ internal class AnalyzerAssertions : ReferenceTypeAssertions { diff --git a/CliFx.Analyzers/CliFx.Analyzers.csproj b/CliFx.Analyzers/CliFx.Analyzers.csproj index 08d300f..ad5ceba 100644 --- a/CliFx.Analyzers/CliFx.Analyzers.csproj +++ b/CliFx.Analyzers/CliFx.Analyzers.csproj @@ -17,11 +17,11 @@ - + - + \ No newline at end of file diff --git a/CliFx.Analyzers/ObjectModel/CommandOptionSymbol.cs b/CliFx.Analyzers/ObjectModel/CommandOptionSymbol.cs index 8893647..ec289a3 100644 --- a/CliFx.Analyzers/ObjectModel/CommandOptionSymbol.cs +++ b/CliFx.Analyzers/ObjectModel/CommandOptionSymbol.cs @@ -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() .FirstOrDefault(); - var validators = attribute.NamedArguments + var validators = attribute + .NamedArguments .Where(a => a.Key == "Validators") .SelectMany(a => a.Value.Values) .Select(c => c.Value) diff --git a/CliFx.Analyzers/ObjectModel/CommandParameterSymbol.cs b/CliFx.Analyzers/ObjectModel/CommandParameterSymbol.cs index ed34a98..a0fb8cb 100644 --- a/CliFx.Analyzers/ObjectModel/CommandParameterSymbol.cs +++ b/CliFx.Analyzers/ObjectModel/CommandParameterSymbol.cs @@ -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() .FirstOrDefault(); - var validators = attribute.NamedArguments + var validators = attribute + .NamedArguments .Where(a => a.Key == "Validators") .SelectMany(a => a.Value.Values) .Select(c => c.Value) diff --git a/CliFx.Analyzers/OptionMustBeInsideCommandAnalyzer.cs b/CliFx.Analyzers/OptionMustBeInsideCommandAnalyzer.cs index 0d8c930..2da7f17 100644 --- a/CliFx.Analyzers/OptionMustBeInsideCommandAnalyzer.cs +++ b/CliFx.Analyzers/OptionMustBeInsideCommandAnalyzer.cs @@ -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) { diff --git a/CliFx.Analyzers/OptionMustHaveUniqueNameAnalyzer.cs b/CliFx.Analyzers/OptionMustHaveUniqueNameAnalyzer.cs index a186fc8..74c7946 100644 --- a/CliFx.Analyzers/OptionMustHaveUniqueNameAnalyzer.cs +++ b/CliFx.Analyzers/OptionMustHaveUniqueNameAnalyzer.cs @@ -35,7 +35,8 @@ public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase if (string.IsNullOrWhiteSpace(option.Name)) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/OptionMustHaveUniqueShortNameAnalyzer.cs b/CliFx.Analyzers/OptionMustHaveUniqueShortNameAnalyzer.cs index eeba515..6a32578 100644 --- a/CliFx.Analyzers/OptionMustHaveUniqueShortNameAnalyzer.cs +++ b/CliFx.Analyzers/OptionMustHaveUniqueShortNameAnalyzer.cs @@ -34,7 +34,8 @@ public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase if (option.ShortName is null) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/OptionMustHaveValidConverterAnalyzer.cs b/CliFx.Analyzers/OptionMustHaveValidConverterAnalyzer.cs index 99a1545..affdbae 100644 --- a/CliFx.Analyzers/OptionMustHaveValidConverterAnalyzer.cs +++ b/CliFx.Analyzers/OptionMustHaveValidConverterAnalyzer.cs @@ -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) diff --git a/CliFx.Analyzers/OptionMustHaveValidValidatorsAnalyzer.cs b/CliFx.Analyzers/OptionMustHaveValidValidatorsAnalyzer.cs index 2e45e35..b831407 100644 --- a/CliFx.Analyzers/OptionMustHaveValidValidatorsAnalyzer.cs +++ b/CliFx.Analyzers/OptionMustHaveValidValidatorsAnalyzer.cs @@ -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 = diff --git a/CliFx.Analyzers/ParameterMustBeInsideCommandAnalyzer.cs b/CliFx.Analyzers/ParameterMustBeInsideCommandAnalyzer.cs index c75fee8..4c443e3 100644 --- a/CliFx.Analyzers/ParameterMustBeInsideCommandAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustBeInsideCommandAnalyzer.cs @@ -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) { diff --git a/CliFx.Analyzers/ParameterMustBeLastIfNonRequiredAnalyzer.cs b/CliFx.Analyzers/ParameterMustBeLastIfNonRequiredAnalyzer.cs index 4991a59..a552aa2 100644 --- a/CliFx.Analyzers/ParameterMustBeLastIfNonRequiredAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustBeLastIfNonRequiredAnalyzer.cs @@ -33,7 +33,8 @@ public class ParameterMustBeLastIfNonRequiredAnalyzer : AnalyzerBase if (parameter.IsRequired != false) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustBeLastIfNonScalarAnalyzer.cs b/CliFx.Analyzers/ParameterMustBeLastIfNonScalarAnalyzer.cs index 033442c..5e071bf 100644 --- a/CliFx.Analyzers/ParameterMustBeLastIfNonScalarAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustBeLastIfNonScalarAnalyzer.cs @@ -33,7 +33,8 @@ public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase if (parameter.IsScalar()) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustBeSingleIfNonRequiredAnalyzer.cs b/CliFx.Analyzers/ParameterMustBeSingleIfNonRequiredAnalyzer.cs index 5638fd3..bd7c9d6 100644 --- a/CliFx.Analyzers/ParameterMustBeSingleIfNonRequiredAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustBeSingleIfNonRequiredAnalyzer.cs @@ -33,7 +33,8 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzer : AnalyzerBase if (parameter.IsRequired != false) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustBeSingleIfNonScalarAnalyzer.cs b/CliFx.Analyzers/ParameterMustBeSingleIfNonScalarAnalyzer.cs index bbf02ea..c67545d 100644 --- a/CliFx.Analyzers/ParameterMustBeSingleIfNonScalarAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustBeSingleIfNonScalarAnalyzer.cs @@ -33,7 +33,8 @@ public class ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase if (parameter.IsScalar()) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustHaveUniqueNameAnalyzer.cs b/CliFx.Analyzers/ParameterMustHaveUniqueNameAnalyzer.cs index cdcc8cc..182c326 100644 --- a/CliFx.Analyzers/ParameterMustHaveUniqueNameAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustHaveUniqueNameAnalyzer.cs @@ -35,7 +35,8 @@ public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase if (string.IsNullOrWhiteSpace(parameter.Name)) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustHaveUniqueOrderAnalyzer.cs b/CliFx.Analyzers/ParameterMustHaveUniqueOrderAnalyzer.cs index 4d4661e..3233956 100644 --- a/CliFx.Analyzers/ParameterMustHaveUniqueOrderAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustHaveUniqueOrderAnalyzer.cs @@ -31,7 +31,8 @@ public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase if (parameter is null) return; - var otherProperties = property.ContainingType + var otherProperties = property + .ContainingType .GetMembers() .OfType() .Where(m => !m.Equals(property)) diff --git a/CliFx.Analyzers/ParameterMustHaveValidConverterAnalyzer.cs b/CliFx.Analyzers/ParameterMustHaveValidConverterAnalyzer.cs index 1de5ff4..c437b8d 100644 --- a/CliFx.Analyzers/ParameterMustHaveValidConverterAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustHaveValidConverterAnalyzer.cs @@ -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) diff --git a/CliFx.Analyzers/ParameterMustHaveValidValidatorsAnalyzer.cs b/CliFx.Analyzers/ParameterMustHaveValidValidatorsAnalyzer.cs index 1ebcd90..bb93351 100644 --- a/CliFx.Analyzers/ParameterMustHaveValidValidatorsAnalyzer.cs +++ b/CliFx.Analyzers/ParameterMustHaveValidValidatorsAnalyzer.cs @@ -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 = diff --git a/CliFx.Analyzers/SystemConsoleShouldBeAvoidedAnalyzer.cs b/CliFx.Analyzers/SystemConsoleShouldBeAvoidedAnalyzer.cs index e64e394..fe13880 100644 --- a/CliFx.Analyzers/SystemConsoleShouldBeAvoidedAnalyzer.cs +++ b/CliFx.Analyzers/SystemConsoleShouldBeAvoidedAnalyzer.cs @@ -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() .SelectMany(m => m.ParameterList.Parameters) diff --git a/CliFx.Analyzers/Utils/Extensions/RoslynExtensions.cs b/CliFx.Analyzers/Utils/Extensions/RoslynExtensions.cs index 00d6c21..6af6801 100644 --- a/CliFx.Analyzers/Utils/Extensions/RoslynExtensions.cs +++ b/CliFx.Analyzers/Utils/Extensions/RoslynExtensions.cs @@ -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() .SelectMany(p => p.Modifiers) diff --git a/CliFx.Benchmarks/CliFx.Benchmarks.csproj b/CliFx.Benchmarks/CliFx.Benchmarks.csproj index 42d1d76..c21eb84 100644 --- a/CliFx.Benchmarks/CliFx.Benchmarks.csproj +++ b/CliFx.Benchmarks/CliFx.Benchmarks.csproj @@ -6,13 +6,13 @@ - + - - - + + + diff --git a/CliFx.Demo/CliFx.Demo.csproj b/CliFx.Demo/CliFx.Demo.csproj index 643f25f..05307d3 100644 --- a/CliFx.Demo/CliFx.Demo.csproj +++ b/CliFx.Demo/CliFx.Demo.csproj @@ -7,7 +7,7 @@ - + diff --git a/CliFx.Tests.Dummy/CliFx.Tests.Dummy.csproj b/CliFx.Tests.Dummy/CliFx.Tests.Dummy.csproj index e8f06cf..3858850 100644 --- a/CliFx.Tests.Dummy/CliFx.Tests.Dummy.csproj +++ b/CliFx.Tests.Dummy/CliFx.Tests.Dummy.csproj @@ -7,7 +7,7 @@ - + diff --git a/CliFx.Tests/CliFx.Tests.csproj b/CliFx.Tests/CliFx.Tests.csproj index 3819c78..e01a474 100644 --- a/CliFx.Tests/CliFx.Tests.csproj +++ b/CliFx.Tests/CliFx.Tests.csproj @@ -9,18 +9,18 @@ - + - - - - + + + + - - - - + + + + diff --git a/CliFx.Tests/Utils/DynamicCommandBuilder.cs b/CliFx.Tests/Utils/DynamicCommandBuilder.cs index 0819aa1..2c03eb9 100644 --- a/CliFx.Tests/Utils/DynamicCommandBuilder.cs +++ b/CliFx.Tests/Utils/DynamicCommandBuilder.cs @@ -31,7 +31,8 @@ internal static class DynamicCommandBuilder }; // Get default CliFx namespaces - var defaultCliFxNamespaces = typeof(ICommand).Assembly + var defaultCliFxNamespaces = typeof(ICommand) + .Assembly .GetTypes() .Where(t => t.IsPublic) .Select(t => t.Namespace) @@ -55,7 +56,9 @@ internal static class DynamicCommandBuilder var compilation = CSharpCompilation.Create( "CliFxTests_DynamicAssembly_" + Guid.NewGuid(), new[] { ast }, - Net70.References.All + Net70 + .References + .All .Append(MetadataReference.CreateFromFile(typeof(ICommand).Assembly.Location)) .Append( MetadataReference.CreateFromFile( diff --git a/CliFx.Tests/Utils/Extensions/AssertionExtensions.cs b/CliFx.Tests/Utils/Extensions/AssertionExtensions.cs index 8cd3a38..8389ffc 100644 --- a/CliFx.Tests/Utils/Extensions/AssertionExtensions.cs +++ b/CliFx.Tests/Utils/Extensions/AssertionExtensions.cs @@ -8,14 +8,10 @@ namespace CliFx.Tests.Utils.Extensions; internal static class AssertionExtensions { - public static void ConsistOfLines(this StringAssertions assertions, IEnumerable lines) - { - var actualLines = assertions.Subject.Split( - new[] { '\n', '\r' }, - StringSplitOptions.RemoveEmptyEntries - ); - actualLines.Should().Equal(lines); - } + public static void ConsistOfLines(this StringAssertions assertions, IEnumerable lines) => + assertions + .Subject + .Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Should().Equal(lines); public static void ConsistOfLines(this StringAssertions assertions, params string[] lines) => assertions.ConsistOfLines((IEnumerable)lines); @@ -33,9 +29,11 @@ internal static class AssertionExtensions if (index < 0) { - Execute.Assertion.FailWith( - $"Expected string '{assertions.Subject}' to contain '{value}' after position {lastIndex}." - ); + Execute + .Assertion + .FailWith( + $"Expected string '{assertions.Subject}' to contain '{value}' after position {lastIndex}." + ); } lastIndex = index; diff --git a/CliFx/CliApplication.cs b/CliFx/CliApplication.cs index c52b8c0..fad2048 100644 --- a/CliFx/CliApplication.cs +++ b/CliFx/CliApplication.cs @@ -72,11 +72,9 @@ public class CliApplication { using (_console.WithForegroundColor(ConsoleColor.Green)) { - var processId = ProcessEx.GetCurrentProcessId(); - - _console.Output.WriteLine( - $"Attach the debugger to process with ID {processId} to continue." - ); + _console + .Output + .WriteLine($"Attach the debugger to process with ID {ProcessEx.GetCurrentProcessId()} to continue."); } // Try to also launch the debugger ourselves (only works with Visual Studio) diff --git a/CliFx/CliFx.csproj b/CliFx/CliFx.csproj index c31224d..c5b1b06 100644 --- a/CliFx/CliFx.csproj +++ b/CliFx/CliFx.csproj @@ -21,9 +21,9 @@ - + - + diff --git a/CliFx/CommandBinder.cs b/CliFx/CommandBinder.cs index 8e0a12d..77cda52 100644 --- a/CliFx/CommandBinder.cs +++ b/CliFx/CommandBinder.cs @@ -152,10 +152,14 @@ internal class CommandBinder try { // Non-scalar - var enumerableUnderlyingType = - memberSchema.Property.Type.TryGetEnumerableUnderlyingType(); + var enumerableUnderlyingType = memberSchema + .Property + .Type + .TryGetEnumerableUnderlyingType(); + if ( - enumerableUnderlyingType is not null && memberSchema.Property.Type != typeof(string) + enumerableUnderlyingType is not null + && memberSchema.Property.Type != typeof(string) ) { return ConvertMultiple( @@ -248,7 +252,8 @@ internal class CommandBinder { // Ensure there are no unexpected parameters and that all parameters are provided var remainingParameterInputs = commandInput.Parameters.ToList(); - var remainingRequiredParameterSchemas = commandSchema.Parameters + var remainingRequiredParameterSchemas = commandSchema + .Parameters .Where(p => p.IsRequired) .ToList(); @@ -317,19 +322,21 @@ internal class CommandBinder { // Ensure there are no unrecognized options and that all required options are set var remainingOptionInputs = commandInput.Options.ToList(); - var remainingRequiredOptionSchemas = commandSchema.Options + var remainingRequiredOptionSchemas = commandSchema + .Options .Where(o => o.IsRequired) .ToList(); foreach (var optionSchema in commandSchema.Options) { - var optionInputs = commandInput.Options + var optionInputs = commandInput + .Options .Where(o => optionSchema.MatchesIdentifier(o.Identifier)) .ToArray(); - var environmentVariableInput = commandInput.EnvironmentVariables.FirstOrDefault( - e => optionSchema.MatchesEnvironmentVariable(e.Name) - ); + var environmentVariableInput = commandInput + .EnvironmentVariables + .FirstOrDefault(e => optionSchema.MatchesEnvironmentVariable(e.Name)); // Direct input if (optionInputs.Any()) diff --git a/CliFx/Formatting/HelpConsoleFormatter.cs b/CliFx/Formatting/HelpConsoleFormatter.cs index 7cdac86..a172e4f 100644 --- a/CliFx/Formatting/HelpConsoleFormatter.cs +++ b/CliFx/Formatting/HelpConsoleFormatter.cs @@ -106,9 +106,9 @@ internal class HelpConsoleFormatter : ConsoleFormatter } // Child command usage - var childCommandSchemas = _context.ApplicationSchema.GetChildCommands( - _context.CommandSchema.Name - ); + var childCommandSchemas = _context + .ApplicationSchema + .GetChildCommands(_context.CommandSchema.Name); if (childCommandSchemas.Any()) { @@ -365,7 +365,8 @@ internal class HelpConsoleFormatter : ConsoleFormatter private void WriteCommandChildren() { - var childCommandSchemas = _context.ApplicationSchema + var childCommandSchemas = _context + .ApplicationSchema .GetChildCommands(_context.CommandSchema.Name) .OrderBy(a => a.Name, StringComparer.Ordinal) .ToArray(); @@ -398,7 +399,8 @@ internal class HelpConsoleFormatter : ConsoleFormatter } // Child commands of child command - var grandChildCommandSchemas = _context.ApplicationSchema + var grandChildCommandSchemas = _context + .ApplicationSchema .GetChildCommands(childCommandSchema.Name) .OrderBy(c => c.Name, StringComparer.Ordinal) .ToArray(); @@ -422,7 +424,8 @@ internal class HelpConsoleFormatter : ConsoleFormatter Write( ConsoleColor.Cyan, // Relative to current command (not the parent) - grandChildCommandSchema.Name + grandChildCommandSchema + .Name ?.Substring(_context.CommandSchema.Name?.Length ?? 0) .Trim() ); diff --git a/CliFx/Schema/ApplicationSchema.cs b/CliFx/Schema/ApplicationSchema.cs index ac3f2bf..8212b0a 100644 --- a/CliFx/Schema/ApplicationSchema.cs +++ b/CliFx/Schema/ApplicationSchema.cs @@ -44,10 +44,9 @@ internal partial class ApplicationSchema string.IsNullOrWhiteSpace(parentCommandName) || // Otherwise a command is a descendant if it starts with the same name segments - potentialParentCommandSchema.Name.StartsWith( - parentCommandName + ' ', - StringComparison.OrdinalIgnoreCase - ); + potentialParentCommandSchema + .Name + .StartsWith(parentCommandName + ' ', StringComparison.OrdinalIgnoreCase); if (isDescendant) result.Add(potentialParentCommandSchema);