From 465f9e5d8eec0e83e6e6bb05f1e9c00e15eab062 Mon Sep 17 00:00:00 2001 From: Kevin B Date: Mon, 15 Feb 2021 16:30:15 -0800 Subject: [PATCH] Making argument internal to option (#1148) * WIP making argument internal to option * Fixing NRT warning * Fixing end to end test app * Updating tests --- .../Perf_Parser_CustomScenarios.cs | 5 +- .../Perf_Parser_Directives_Suggest.cs | 16 +- .../CommandLine/Perf_Parser_Options_Bare.cs | 8 +- .../Perf_Parser_Options_With_Arguments.cs | 8 +- .../CommandLine/Perf_Suggestions.cs | 10 +- .../ConfigureFromMethodTests.cs | 2 +- .../CommandLine.cs | 20 +- .../HostingTests.cs | 5 +- .../EndToEndTestApp/Program.cs | 20 +- src/System.CommandLine.Tests/ArgumentTests.cs | 21 +- .../Binding/ModelBinderTests.cs | 80 +--- .../ModelBindingCommandHandlerTests.cs | 73 +--- .../Binding/TypeConversionTests.cs | 218 ++-------- src/System.CommandLine.Tests/CommandTests.cs | 8 +- .../Help/HelpBuilderTests.Approval.cs | 35 +- .../Help/HelpBuilderTests.cs | 74 +--- .../Invocation/CommandHandlerTests.cs | 122 +----- src/System.CommandLine.Tests/OptionTests.cs | 64 +-- .../ParseDiagramTests.cs | 28 +- .../ParserTests.MultipleArguments.cs | 5 +- .../ParserTests.MultiplePositions.cs | 15 +- src/System.CommandLine.Tests/ParserTests.cs | 401 +++--------------- .../ParsingValidationTests.cs | 67 +-- .../ResponseFileTests.cs | 38 +- .../SuggestDirectiveTests.cs | 5 +- .../SuggestionTests.cs | 238 +++-------- .../SymbolResultTests.cs | 10 +- src/System.CommandLine/Argument.cs | 4 +- src/System.CommandLine/Help/HelpOption.cs | 4 +- src/System.CommandLine/Option.cs | 89 +++- src/System.CommandLine/Option{T}.cs | 73 ++-- 31 files changed, 416 insertions(+), 1350 deletions(-) diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_CustomScenarios.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_CustomScenarios.cs index 942471f05..74d9215db 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_CustomScenarios.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_CustomScenarios.cs @@ -20,10 +20,7 @@ public void SetupOneOptWithNestedCommand() { var rootCommand = new Command("root_command"); var nestedCommand = new Command("nested_command"); - var option = new Option("-opt1") - { - Argument = new Argument(() => 123) - }; + var option = new Option("-opt1", () => 123); nestedCommand.AddOption(option); rootCommand.AddCommand(nestedCommand); diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs index 257e4aeb0..c3a0e2b9d 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs @@ -26,20 +26,8 @@ public void Setup() var eatCommand = new Command("eat") { - new Option("--fruit") - { - Argument = new Argument() - { - Suggestions = {"apple", "banana", "cherry" } - } - }, - new Option("--vegetable") - { - Argument = new Argument() - { - Suggestions = {"asparagus", "broccoli", "carrot" } - } - } + new Option("--fruit").AddSuggestions("apple", "banana", "cherry"), + new Option("--vegetable").AddSuggestions("asparagus", "broccoli", "carrot") }; _testParser = new CommandLineBuilder(eatCommand) diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_Bare.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_Bare.cs index 926b86cfe..5ed969570 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_Bare.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Options_Bare.cs @@ -21,13 +21,9 @@ public class Perf_Parser_Options_Bare private IEnumerable