-
Notifications
You must be signed in to change notification settings - Fork 643
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Information
- OS:
macOS 14.3 - Version:
0.48.0 - .NET Version:
8.0.100
Describe the bug
Using the AddDelegate method on a command branch produces a MissingMethodException.
To Reproduce
- Create a simple CLI app
- Add a branch
- Use
AddDelegate - Run the app
...
var app = new CommandApp();
app.Configure(cfg => {
cfg.AddBranch("demo", d => {
d.AddDelegate("delegate", ctx => {
AnsiConsole.MarkupLine("[red]This doesn't work[/]");
return 0;
});
});
});
...
app.Run(args);This produces a MissingMethodException.
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.
at System.RuntimeType.ActivatorCache..ctor(RuntimeType rt)
at object System.RuntimeType.CreateInstanceDefaultCtor(bool publicOnly, bool wrapExceptions)
at object Spectre.Console.Cli.TypeResolverAdapter.Resolve(Type type) in /_/src/Spectre.Console.Cli/Internal/TypeResolverAdapter.cs:28
at object Spectre.Console.Cli.TypeResolverAdapter.Resolve(Type type) in /_/src/Spectre.Console.Cli/Internal/TypeResolverAdapter.cs:36
at CommandSettings Spectre.Console.Cli.CommandPropertyBinder.CreateSettings(ITypeResolver resolver, Type settingsType) in /_/src/Spectre.Console.Cli/Internal/Binding/
CommandPropertyBinder.cs:29
at CommandSettings Spectre.Console.Cli.CommandPropertyBinder.CreateSettings(CommandValueLookup lookup, Type settingsType, ITypeResolver resolver) in
/_/src/Spectre.Console.Cli/Internal/Binding/CommandPropertyBinder.cs:7
at CommandSettings Spectre.Console.Cli.CommandBinder.Bind(CommandTree tree, Type settingsType, ITypeResolver resolver) in /_/src/Spectre.Console.Cli/Internal/CommandBinder.cs:26
at Task<int> Spectre.Console.Cli.CommandExecutor.Execute(CommandTree leaf, CommandTree tree, CommandContext context, ITypeResolver resolver, IConfiguration configuration) in
/_/src/Spectre.Console.Cli/Internal/CommandExecutor.cs:132
at async Task<int> Spectre.Console.Cli.CommandExecutor.Execute(IConfiguration configuration, IEnumerable<string> args) in /_/src/Spectre.Console.Cli/Internal/CommandExecutor.cs:83
at async Task<int> Spectre.Console.Cli.CommandApp.RunAsync(IEnumerable<string> args) in /_/src/Spectre.Console.Cli/CommandApp.cs:84
at int Spectre.Console.Cli.CommandApp.Run(IEnumerable<string> args) in /_/src/Spectre.Console.Cli/CommandApp.cs:58
at int Program.Main(string[] args) in /.../Program.cs:90
Expected behavior
The delegate function runs and prints "This doesn't work" in red
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working