From ba783e442b31cd3ab8ee4ddc922f2c68de864cc7 Mon Sep 17 00:00:00 2001 From: Jon Sequeira Date: Sun, 12 Apr 2020 11:08:55 -0700 Subject: [PATCH] enable easier custom model binding --- .../ConfigureFromMethodTests.cs | 2 +- .../CommandLine.cs | 4 +- .../Binding/HandlerDescriptorTests.cs | 29 +------- .../Binding/ModelBinderTests.cs | 70 +++++++++++++++++-- .../Binding/TestModels.cs | 1 - src/System.CommandLine/Argument.cs | 2 +- .../Binding/BindingContext.cs | 42 +++++------ src/System.CommandLine/Binding/BoundValue.cs | 4 +- .../Binding/DelegateHandlerDescriptor.cs | 6 +- .../Binding/ExpressionHandlerDescriptor.cs | 60 ---------------- .../Binding/HandlerDescriptor.cs | 11 +-- .../Binding/IValueDescriptor.cs | 2 +- .../Binding/MethodInfoHandlerDescriptor.cs | 18 ++--- src/System.CommandLine/Binding/ModelBinder.cs | 30 ++++---- .../Binding/ModelDescriptor.cs | 40 +++-------- .../Binding/ParameterDescriptor.cs | 10 +-- .../Binding/PropertyDescriptor.cs | 6 +- .../Binding/ServiceProviderValueSource.cs | 2 +- .../Binding/TypeDefaultValueSource.cs | 2 +- src/System.CommandLine/Help/HelpBuilder.cs | 2 +- .../Invocation/ModelBindingCommandHandler.cs | 30 ++++---- .../Invocation/ServiceProvider.cs | 18 +++-- src/System.CommandLine/Option.cs | 2 +- .../Parsing/CommandResultExtensions.cs | 2 +- .../Parsing/ParseOperation.cs | 4 +- .../Parsing/ParseResultVisitor.cs | 2 +- 26 files changed, 170 insertions(+), 231 deletions(-) delete mode 100644 src/System.CommandLine/Binding/ExpressionHandlerDescriptor.cs diff --git a/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs b/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs index 1fa2b13390..0a9db21aba 100644 --- a/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs +++ b/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs @@ -162,7 +162,7 @@ public void Parameters_named_arguments_generate_command_arguments_having_the_cor var rootCommandArgument = parser.Configuration.RootCommand.Arguments.Single(); - rootCommandArgument.Type + rootCommandArgument.ValueType .Should() .Be(expectedType); } diff --git a/src/System.CommandLine.DragonFruit/CommandLine.cs b/src/System.CommandLine.DragonFruit/CommandLine.cs index 380362c94c..63e7bd7f0a 100644 --- a/src/System.CommandLine.DragonFruit/CommandLine.cs +++ b/src/System.CommandLine.DragonFruit/CommandLine.cs @@ -279,7 +279,7 @@ public static IEnumerable