You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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.
This was fixed with #2060, in the sense that AddGlobalOption was replaced with the public property Option.AppliesToSelfAndChildren; developers who set that won't be surprised that it affects the option in every command to which the option is added.
(AppliesToSelfAndChildren was subsequently renamed to Recursive in #2132.)
Activity
KalleOlaviNiemitalo commentedon Apr 3, 2023
This was fixed with #2060, in the sense that AddGlobalOption was replaced with the public property Option.AppliesToSelfAndChildren; developers who set that won't be surprised that it affects the option in every command to which the option is added.
(AppliesToSelfAndChildren was subsequently renamed to Recursive in #2132.)
jonsequitur commentedon Apr 3, 2023
Thanks for point this out, @KalleOlaviNiemitalo!