Skip to content

Fix overriding HelpName in Parser.cs, set it explicitly instead #49423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akoeplinger
Copy link
Member

Follow-up to #48817 and #49418.

There were only a couple commands where the option HelpName was overridden by EnsureHelpName, make those explicit instead and add a test that verifies all options comply.

Only one place remains that is still using EnsureHelpName, but it's not feasible to change this as we'd need to change every template:

IEnumerable<TwoColumnHelpRow> optionsToWrite = optionsToShow.Select(o =>
{
o.Option.EnsureHelpName();
return context.HelpBuilder.GetTwoColumnRow(o.Option, context);
});

Follow-up to dotnet#48817 and dotnet#49418.

There were only a couple commands where the option HelpName was overridden, make those explicit instead and add a test that verifies all options comply.
@akoeplinger akoeplinger requested a review from a team as a code owner June 16, 2025 19:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the issue of overriding HelpName in command options by explicitly setting it instead of calling the EnsureHelpName method. In summary, the changes include:

  • Explicit assignment of HelpName on options in ReferenceCommandParser, NuGetCommandParser, and SharedOptions.
  • Modifying SymbolExtensions to return a bool instead of void when setting HelpName.
  • Removing the EnsureHelpName invocations from InstantiateCommand.Help, along with updating resource files (xlf/resx) to support the new approach.

Reviewed Changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Cli/dotnet/Commands/Reference/ReferenceCommandParser.cs Now sets HelpName explicitly for the project option.
src/Cli/dotnet/Commands/NuGet/NuGetCommandParser.cs Adds explicit HelpName and description for the verbosity option.
src/Cli/Microsoft.TemplateEngine.Cli/SymbolExtensions.cs Changes EnsureHelpName to return bool instead of void.
src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs Removes bulk invocation of EnsureHelpName on options.
xlf/resx files Add new trans-units/resources to support HelpName strings.
src/Cli/Microsoft.TemplateEngine.Cli/Commands/SharedOptions.cs Updates options to set HelpName explicitly.
Files not reviewed (1)
  • src/Cli/Microsoft.TemplateEngine.Cli/Commands/SymbolStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

src/Cli/Microsoft.TemplateEngine.Cli/SymbolExtensions.cs:11

  • Update the XML documentation (or equivalent comments) for EnsureHelpName to clearly describe its side effects and new return value so that callers know how to handle the result.
public static bool EnsureHelpName(this Option cliOption)

src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs:320

  • Ensure that all options displayed by the help command already have the HelpName property explicitly set, since the removal of the EnsureHelpName call here could result in missing HelpName values if any option was not updated elsewhere.
foreach (Option cliOption in optionsToShow) { cliOption.EnsureHelpName(); }

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.

2 participants