Skip to content

Option.IsGlobal creates potential unintended behavior when an option is used in more than one subcommand but is not intended to be global in both #1728

Closed
@jonsequitur

Description

@jonsequitur

The current implementation of Command.AddGlobalOption sets Option.IsGlobal, which can result in an unintended behavior when an option is used in more than one command and is intended to be global in one case but not in another.

In the following example, the second parse should result in a parse error because option was not added globally to childCommand2, but there is no parse error because AddGlobalOption was called on the same option. This bug will manifest regardless of the call order.

image

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