Skip to content

Cannot use more than 8 options on one command #1878

Closed

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.

Activity

  1. KalleOlaviNiemitalo commented on Oct 20, 2022

    @KalleOlaviNiemitalo

    The change was announced in #1750 (comment):

    Finally, we've reduced the number of SetHandler overloads. Where before there were overloads supporting up to sixteen generic parameters, they now only go up to eight.

    I don't know why the API documentation still hasn't been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Documentationbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions