I would like a Source Generator that supports implementing ICommandHandler like DragonFruit.
For example, for the following code,
partial class CommandHandler
{
[CommandHandler]
Task<int> Handle(
int foo)
{
// command handling
}
}
generates following implementation.
partial class CommandHandler : ICommandHandler
{
public Task<int> InvokeAsync(InvocationContext context)
{
var fooOption = context.ParseResult.CommandResult.Command.Options
.SingleOrDefault(static option => option.Name == "foo");
var fooValue = context.ParseResult.GetValueForOption(fooOption);
return this.Handle(fooValue);
}
}
The above code is for a very simple case; more considerations are needed for what actually works.