You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
AddAsyncDelegate without custom settings throws CommandRuntimeException on invocation.
Spectre.Console.Cli.CommandRuntimeException: Could not resolve type 'Spectre.Console.Cli.CommandSettings'.
---> System.MissingMethodException: Cannot dynamically create an instance of type 'Spectre.Console.Cli.CommandSettings'. Reason: Cannot create an abstract class.
To Reproduce
usingSpectre.Console.Cli;varapp=newCommandApp();app.Configure(cfg =>{cfg.PropagateExceptions();cfg.AddBranch("sample", s =>{s.AddAsyncDelegate("async-test",async context =>{awaitConsole.Out.WriteLineAsync("Hello from async delegate");return0;});s.AddDelegate("sync-test", context =>{Console.WriteLine("Hello from sync delegate");return0;});});});returnawaitapp.RunAsync(args);
Invoking the program using sample async-test throws an exception, while invoking using sample sync-test prints "Hello from sync delegate".
Expected behavior
AddAsyncDelegate and AddDelegate should behave in the same way, i.e. just invoke the provided delegate
Additional context
As a workaround it's possible to call AddBranch<EmptyCommandSettings>(...) and get the expected behavior.
AddDelegate currently performs a type check using Type.IsAbstracthere to fix #1507. while no such check is done when configuring an async delegate.
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered:
Information
Describe the bug
AddAsyncDelegate without custom settings throws CommandRuntimeException on invocation.
Spectre.Console.Cli.CommandRuntimeException: Could not resolve type 'Spectre.Console.Cli.CommandSettings'.
---> System.MissingMethodException: Cannot dynamically create an instance of type 'Spectre.Console.Cli.CommandSettings'. Reason: Cannot create an abstract class.
To Reproduce
Invoking the program using
sample async-test
throws an exception, while invoking usingsample sync-test
prints "Hello from sync delegate".Expected behavior
AddAsyncDelegate and AddDelegate should behave in the same way, i.e. just invoke the provided delegate
Additional context
As a workaround it's possible to call
AddBranch<EmptyCommandSettings>(...)
and get the expected behavior.AddDelegate currently performs a type check using
Type.IsAbstract
here to fix #1507. while no such check is done when configuring an async delegate.Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: