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

@@ -8,9 +8,9 @@ public partial class Benchmarks
public class CoconaCommand
{
public void Execute(
[Option("str", new[] { 's' })] string? strOption,
[Option("int", new[] { 'i' })] int intOption,
[Option("bool", new[] { 'b' })] bool boolOption
[Option("str", ['s'])] string? strOption,
[Option("int", ['i'])] int intOption,
[Option("bool", ['b'])] bool boolOption
) { }
}

View File

@@ -15,9 +15,9 @@ public partial class Benchmarks
{
var command = new RootCommand
{
new Option(new[] { "--str", "-s" }) { Argument = new Argument<string?>() },
new Option(new[] { "--int", "-i" }) { Argument = new Argument<int>() },
new Option(new[] { "--bool", "-b" }) { Argument = new Argument<bool>() }
new Option(["--str", "-s"]) { Argument = new Argument<string?>() },
new Option(["--int", "-i"]) { Argument = new Argument<int>() },
new Option(["--bool", "-b"]) { Argument = new Argument<bool>() }
};
command.Handler = CommandHandler.Create(

View File

@@ -9,7 +9,7 @@ namespace CliFx.Benchmarks;
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
public partial class Benchmarks
{
private static readonly string[] Arguments = { "--str", "hello world", "-i", "13", "-b" };
private static readonly string[] Arguments = ["--str", "hello world", "-i", "13", "-b"];
public static void Main() =>
BenchmarkRunner.Run<Benchmarks>(