Skip to content

Fix #2621 - add option action to preactions when option has a default value#2708

Merged
jonsequitur merged 4 commits intodotnet:mainfrom
jonsequitur:fix-2621
Apr 2, 2026
Merged

Fix #2621 - add option action to preactions when option has a default value#2708
jonsequitur merged 4 commits intodotnet:mainfrom
jonsequitur:fix-2621

Conversation

@jonsequitur
Copy link
Copy Markdown
Contributor

This fixes #2621. It ensures that an option with a pre-action is still invoked if it has a default value but the option is not specified on the command line.

@jonsequitur jonsequitur marked this pull request as draft October 16, 2025 23:33
@jonsequitur jonsequitur force-pushed the fix-2621 branch 3 times, most recently from d6ff1c6 to bb817c6 Compare October 16, 2025 23:42
@jonsequitur jonsequitur marked this pull request as ready for review March 31, 2026 22:50
@jonsequitur jonsequitur changed the title Fix #2621 Fix #2621 - add option action to preactions when option has a default value Mar 31, 2026
Copy link
Copy Markdown
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it has a chance of being breaking, but I think it's a reasonable risk to take on it as it's definitely intentional when the option is defined to have an associated action, defaulting to true.

Comment thread src/System.CommandLine/Parsing/ParseOperation.cs Outdated
@jonsequitur jonsequitur enabled auto-merge (squash) April 2, 2026 15:44
@jonsequitur jonsequitur merged commit a0809ce into dotnet:main Apr 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option with default value does not have Action added to PreActions

2 participants