Repository navigation
Suppress default values for .NET CLI flag options - #55928
Conversation
|
Azure Pipelines: 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: marcpopMSFT <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
baronfel
left a comment
There was a problem hiding this comment.
This is pretty much what I was hoping to see, @marcpopMSFT!
There was a problem hiding this comment.
Pull request overview
This PR updates .NET SDK CLI help rendering so presence-only bool flags no longer display [default: False] in --help output, and adjusts some dotnet solution add option definitions accordingly. It also refreshes help-output baselines and adds a focused test to distinguish zero-arity flags from value-taking boolean options.
Changes:
- Suppress default-value rendering for zero-arity
boolOptions in the CLI help formatter. - Update
dotnetcommand help baselines to remove[default: False]for flag options. - Change
dotnet solution addoption arities for--in-root/--include-referencesand add a formatter-level regression test.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Solution/List/GivenDotnetSlnList.cs | Updates help baseline to remove [default: False] from a boolean flag option. |
| test/dotnet.Tests/CommandTests/Solution/Add/GivenDotnetSlnAdd.cs | Updates help baseline for dotnet sln add, reflecting changed default rendering. |
| test/dotnet.Tests/CommandTests/Reference/Add/GivenDotnetAddReference.cs | Updates help baseline to remove [default: False] for --interactive. |
| test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs | Updates help baseline to remove [default: False] for --interactive. |
| test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetMSBuildBuildsProjects.cs | Adds a regression test validating default suppression for zero-arity boolean options. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Help/HelpBuilder.Default.cs | Implements default suppression logic for zero-arity boolean options in help formatting. |
| src/Cli/Microsoft.DotNet.Cli.Definitions/Commands/Solution/SolutionAddCommandDefinition.cs | Changes dotnet sln add option arities (notably --in-root / --include-references). |
| { | ||
| Description = CommandDefinitionStrings.SolutionAddReferencedProjectsOptionDescription, | ||
| DefaultValueFactory = (_) => true, | ||
| Arity = ArgumentArity.Zero, | ||
| }; |
@baronfel looking through the behavior here, I think it's shown us a few cases where we can remove flags. --interactive is always on as is --include-references. Those flags don't do anything anymore (they were once off by default). Since they don't take a bool, you can't set them to false. Should we just remove them from the help for those commands? We could make them hidden so as not to break existing customers or just remove in 12 entirely. Thoughts? (or should we make them full booleans?) |
|
IMO interactive needs a forcing capability so it needs a boolean - we don't currently have a way to force non-interactive the way we can force interactivity. The other two examples from this PR are less impactful and could be hidden for a release. It's probably to late to remove them entirely. |
|
@copilot it looks like --interactive is now on by default so the existing flag doesn't make sense anymore. Can you change that to be a boolean option so customers can do --interactive false? Additionally, any other flags that are on by default like --include-references we should just hide since they don't make a difference anymore? The interactive one we want to keep but the rest that are already default to on can be hidden. |
Co-authored-by: marcpopMSFT <[email protected]>
Implemented in dc824eb: |
|
@copilot fix the tests that are failing:
|
Co-authored-by: marcpopMSFT <[email protected]>
Co-authored-by: marcpopMSFT <[email protected]>
Co-authored-by: marcpopMSFT <[email protected]>
Co-authored-by: marcpopMSFT <[email protected]>
Evangelink
left a comment
There was a problem hiding this comment.
The existing --include-references compatibility concern still applies to the current head.
Before this change, the integration test explicitly verified that --include-references=false succeeded and suppressed recursive project inclusion. Setting Arity = ArgumentArity.Zero makes that value invalid, while the revised test removes the regression coverage. Hiding the default-on option is compatible; changing its arity is not. Please preserve the value-taking behavior while hiding it, or provide a compatible way to opt out.
I’m not approving this revision while that regression remains.
Note
This review was generated with AI assistance.
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 91319485-3056-4ffd-8f48-f06f589c118e
Copilot-Session: 91319485-3056-4ffd-8f48-f06f589c118e
Copilot-Session: 91319485-3056-4ffd-8f48-f06f589c118e
Evangelink
left a comment
There was a problem hiding this comment.
Reviewed the current head with no blocking or warning-level findings. The hidden --include-references option preserves explicit true/false values, shared --interactive false consumers honor the parsed value, and the flag-default suppression is covered across formatter, schema, command help, and approval tests.
Note
This review was generated with AI assistance.
CLI flags such as
--ucrare presence-only options, but help output displayed[default: False], suggesting they accept boolean values. This was inconsistent across commands and obscured that--use-current-runtime falseis not valid flag syntax.Help rendering
booloptions.Flag definitions
dotnet solution add --in-rootand--include-referencesas zero-arity flags.Coverage