Skip to content

Cannot use more than 8 options on one command #1878

Closed
@winterleitner

Description

@winterleitner

I just stumbled across this weird behaviour.

This will compile.

var stringOption = new Option<string?>(name: "--test", description: "Test Option",
    getDefaultValue: () => null);

var cmd = new Command("testcommand", "This has 7 arguments");
cmd.SetHandler(async (a, b, c, d, e, f, g, h) => {}, 
    stringOption, stringOption, stringOption, stringOption, stringOption,
    stringOption, stringOption, stringOption);

while this won't.

var stringOption = new Option<string?>(name: "--test", description: "Test Option",
    getDefaultValue: () => null);

var cmd = new Command("testcommand", "Tests more than 7 arguments, this example has 8");
cmd.SetHandler(async (a, b, c, d, e, f, g, h, i) => {}, 
    stringOption, stringOption, stringOption, stringOption, stringOption,
    stringOption, stringOption, stringOption, stringOption);

All I did change here was add one more parameter. According to the docs, there should be overloads for up to 16 parameters.

Any ideas what is going on?

Edit

Looking into the Handler.Func.cs source file (partial class), there are actually only implementations up to 8 generic parameters. Unfortunately, the AnonymousCommandHandler class used in the methods is internal, so it cannot easily be extended.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions