RunCommandLineApplicationAsync fails after update 3.1.0->4.0.1
Describe the bug
After an update from 3.1.0 to 4.0.1 I see an exception:
System.InvalidOperationException
HResult=0x80131509
Message=Could not find a way to set McMaster.Extensions.CommandLineUtils.CommandLineApplication.RemainingArguments. Try adding a private setter.
Source=McMaster.Extensions.CommandLineUtils
StackTrace:
at McMaster.Extensions.CommandLineUtils.ReflectionHelper.GetPropertySetter(PropertyInfo prop)
at McMaster.Extensions.CommandLineUtils.Conventions.RemainingArgsPropertyConvention.Apply(ConventionContext context)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Builder.McMaster.Extensions.CommandLineUtils.Conventions.IConventionBuilder.AddConvention(IConvention convention)
at McMaster.Extensions.CommandLineUtils.ConventionBuilderExtensions.SetRemainingArgsPropertyOnModel(IConventionBuilder builder)
at McMaster.Extensions.CommandLineUtils.ConventionBuilderExtensions.UseDefaultConventions(IConventionBuilder builder)
at McMaster.Extensions.Hosting.CommandLine.Internal.CommandLineService1..ctor(ILogger1 logger, CommandLineState state, IServiceProvider serviceProvider, Action1 configure) at System.RuntimeMethodHandle.InvokeMethod(Object target, Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
3.1.0 works fine. Full sample to reproduce is here https://github.com/krylatij/McMasterGenericHostBug41
` await new HostBuilder() .ConfigureLogging((context, builder) => { builder.AddConsole(opt => { opt.TimestampFormat = "[HH:mm:ss]"; }); }) .ConfigureServices((context, services) => { services.AddSingleton<TestCommand>(); }) .RunCommandLineApplicationAsync<App>(args);
[Subcommand(typeof(TestCommand))] public class App : CommandLineApplication { }
[Command(Name = "test")] public class TestCommand { public void OnExecute() { Console.WriteLine("hello world."); } } `