Use latest C# features

This commit is contained in:
Tyrrrz
2024-01-12 00:10:27 +02:00
parent 76e8d47e03
commit 6aa72e45e8
30 changed files with 186 additions and 390 deletions

View File

@@ -32,8 +32,8 @@ public class ApplicationSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutp
var app = new CliApplicationBuilder()
.AddCommand<NoOpCommand>()
.AddCommandsFrom(typeof(NoOpCommand).Assembly)
.AddCommands(new[] { typeof(NoOpCommand) })
.AddCommandsFrom(new[] { typeof(NoOpCommand).Assembly })
.AddCommands([typeof(NoOpCommand)])
.AddCommandsFrom([typeof(NoOpCommand).Assembly])
.AddCommandsFromThisAssembly()
.AllowDebugMode()
.AllowPreviewMode()

View File

@@ -9,7 +9,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net70" Version="1.4.5" />
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.4.5" />
<PackageReference Include="CliWrap" Version="3.6.4" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="CSharpier.MsBuild" Version="0.26.5" PrivateAssets="all" />

View File

@@ -38,10 +38,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "xyz" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "xyz"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -78,10 +75,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "xyz" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "xyz"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -128,7 +122,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "true", "-b", "false", "-c" },
["-f", "true", "-b", "false", "-c"],
new Dictionary<string, string>()
);
@@ -167,10 +161,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "32" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "32"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -208,7 +199,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "32.14" },
["-f", "32.14"],
new Dictionary<string, string>()
);
@@ -248,7 +239,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "1995-04-28Z" },
["-f", "1995-04-28Z"],
new Dictionary<string, string>()
);
@@ -288,7 +279,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "12:34:56" },
["-f", "12:34:56"],
new Dictionary<string, string>()
);
@@ -329,10 +320,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "two" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "two"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -374,10 +362,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-b", "123" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-b", "123"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -421,10 +406,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-b", "two" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-b", "two"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -468,10 +450,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "xyz" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "xyz"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -534,7 +513,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "hello", "-b", "world" },
["-f", "hello", "-b", "world"],
new Dictionary<string, string>()
);
@@ -580,7 +559,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "hello world" },
["-f", "hello world"],
new Dictionary<string, string>()
);
@@ -622,7 +601,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "two", "three" },
["-f", "one", "two", "three"],
new Dictionary<string, string>()
);
@@ -664,7 +643,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "two", "three" },
["-f", "one", "two", "three"],
new Dictionary<string, string>()
);
@@ -706,7 +685,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "two", "three" },
["-f", "one", "two", "three"],
new Dictionary<string, string>()
);
@@ -748,7 +727,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "1", "13", "27" },
["-f", "1", "13", "27"],
new Dictionary<string, string>()
);
@@ -787,10 +766,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "xyz" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "xyz"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -831,7 +807,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "two" },
["-f", "one", "two"],
new Dictionary<string, string>()
);
@@ -867,7 +843,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "12.34" },
["-f", "12.34"],
new Dictionary<string, string>()
);
@@ -898,7 +874,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
[Command]
public class Command : ICommand
{
[CommandOption('f', Validators = new[] {typeof(ValidatorA), typeof(ValidatorB)})]
[CommandOption('f', Validators = [typeof(ValidatorA), typeof(ValidatorB)])]
public int Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
@@ -912,10 +888,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "12" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "12"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -957,10 +930,7 @@ public class ConversionSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "bar" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["-f", "bar"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);

View File

@@ -63,7 +63,7 @@ public class DirectivesSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutpu
// Act
var exitCode = await application.RunAsync(
new[] { "[preview]", "cmd", "param", "-abc", "--option", "foo" },
["[preview]", "cmd", "param", "-abc", "--option", "foo"],
new Dictionary<string, string> { ["ENV_QOP"] = "hello", ["ENV_KIL"] = "world" }
);

View File

@@ -48,7 +48,7 @@ public class EnvironmentSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutp
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "42" },
["--foo", "42"],
new Dictionary<string, string> { ["ENV_FOO"] = "100", ["ENV_BAR"] = "200" }
);

View File

@@ -55,10 +55,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -95,10 +92,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -141,7 +135,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
// Act
var exitCode = await application.RunAsync(
new[] { "cmd", "--help" },
["cmd", "--help"],
new Dictionary<string, string>()
);
@@ -186,7 +180,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
// Act
var exitCode = await application.RunAsync(
new[] { "cmd", "sub", "--help" },
["cmd", "sub", "--help"],
new Dictionary<string, string>()
);
@@ -209,7 +203,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
// Act
var exitCode = await application.RunAsync(
new[] { "invalid-command", "--invalid-option" },
["invalid-command", "--invalid-option"],
new Dictionary<string, string>()
);
@@ -235,10 +229,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -268,10 +259,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -307,10 +295,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -349,10 +334,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -398,10 +380,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -440,10 +419,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -481,10 +457,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -523,10 +496,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -566,7 +536,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
// Act
var exitCode = await application.RunAsync(
new[] { "cmd", "--help" },
["cmd", "--help"],
new Dictionary<string, string>()
);
@@ -609,10 +579,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -665,10 +632,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -721,10 +685,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -777,10 +738,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -846,10 +804,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -927,10 +882,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -1001,10 +953,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--help" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--help"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -1035,10 +984,7 @@ public class HelpTextSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--version" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--version"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);

View File

@@ -39,10 +39,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--foo" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--foo"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -79,7 +76,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
.Build();
// Act
var exitCode = await application.RunAsync(new[] { "-f" }, new Dictionary<string, string>());
var exitCode = await application.RunAsync(["-f"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -122,7 +119,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "--bar", "two" },
["--foo", "one", "--bar", "two"],
new Dictionary<string, string>()
);
@@ -167,7 +164,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "-b", "two" },
["-f", "one", "-b", "two"],
new Dictionary<string, string>()
);
@@ -212,7 +209,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "-fb", "value" },
["-fb", "value"],
new Dictionary<string, string>()
);
@@ -254,7 +251,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "two", "three" },
["--foo", "one", "two", "three"],
new Dictionary<string, string>()
);
@@ -296,7 +293,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "two", "three" },
["-f", "one", "two", "three"],
new Dictionary<string, string>()
);
@@ -338,7 +335,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "--foo", "two", "--foo", "three" },
["--foo", "one", "--foo", "two", "--foo", "three"],
new Dictionary<string, string>()
);
@@ -380,7 +377,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "-f", "one", "-f", "two", "-f", "three" },
["-f", "one", "-f", "two", "-f", "three"],
new Dictionary<string, string>()
);
@@ -422,7 +419,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "-f", "two", "--foo", "three" },
["--foo", "one", "-f", "two", "--foo", "three"],
new Dictionary<string, string>()
);
@@ -467,7 +464,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one" },
["--foo", "one"],
new Dictionary<string, string>()
);
@@ -541,7 +538,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
.Build();
// Act
var exitCode = await application.RunAsync(new[] { "--foo", "42", "--bar", "--baz", "xyz" });
var exitCode = await application.RunAsync(["--foo", "42", "--bar", "--baz", "xyz"]);
// Assert
exitCode.Should().Be(0);
@@ -579,7 +576,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "-13" },
["--foo", "-13"],
new Dictionary<string, string>()
);
@@ -650,10 +647,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--foo" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--foo"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -686,10 +680,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "--foo" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["--foo"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -723,7 +714,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "--bar", "two" },
["--foo", "one", "--bar", "two"],
new Dictionary<string, string>()
);
@@ -759,7 +750,7 @@ public class OptionBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOu
// Act
var exitCode = await application.RunAsync(
new[] { "--foo", "one", "two", "three" },
["--foo", "one", "two", "three"],
new Dictionary<string, string>()
);

View File

@@ -43,10 +43,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "one", "two" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["one", "two"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -98,7 +95,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
// Act
var exitCode = await application.RunAsync(
new[] { "one", "two", "three", "four", "five", "--boo", "xxx" },
["one", "two", "three", "four", "five", "--boo", "xxx"],
new Dictionary<string, string>()
);
@@ -138,10 +135,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "one" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["one"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -177,10 +171,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "one" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["one"], new Dictionary<string, string>());
// Assert
exitCode.Should().NotBe(0);
@@ -222,10 +213,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "abc" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["abc"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -262,7 +250,7 @@ public class ParameterBindingSpecs(ITestOutputHelper testOutput) : SpecsBase(tes
// Act
var exitCode = await application.RunAsync(
new[] { "one", "two", "three" },
["one", "two", "three"],
new Dictionary<string, string>()
);

View File

@@ -112,10 +112,7 @@ public class RoutingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
.Build();
// Act
var exitCode = await application.RunAsync(
new[] { "cmd" },
new Dictionary<string, string>()
);
var exitCode = await application.RunAsync(["cmd"], new Dictionary<string, string>());
// Assert
exitCode.Should().Be(0);
@@ -170,7 +167,7 @@ public class RoutingSpecs(ITestOutputHelper testOutput) : SpecsBase(testOutput)
// Act
var exitCode = await application.RunAsync(
new[] { "cmd", "child" },
["cmd", "child"],
new Dictionary<string, string>()
);

View File

@@ -49,14 +49,14 @@ internal static class DynamicCommandBuilder
// Parse the source code
var ast = SyntaxFactory.ParseSyntaxTree(
SourceText.From(sourceCodeWithUsings),
CSharpParseOptions.Default
CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview)
);
// Compile the code to IL
var compilation = CSharpCompilation.Create(
"CliFxTests_DynamicAssembly_" + Guid.NewGuid(),
new[] { ast },
Net70
[ast],
Net80
.References
.All
.Append(MetadataReference.CreateFromFile(typeof(ICommand).Assembly.Location))