Skip to content

stop using System.CommandLine types that aren't public anymore #49181

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 9 commits into
base: main
Choose a base branch
from

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented May 28, 2025

First of all, I've tried to eliminate the need of using the Help APIs that were made internal. For example, for options that were shared between multiple commands, we were using WithHelpDescription to set a custom description. The fix was to simply have a dedicated copy of given option for every command, with a unique description. This had a side effect of generating completions with descriptions that are more accurate (hence the test file update).

When I got to the point where it was not worth the effort, I've followed the plan we have established offline: just copy pasting the internal types here. I've added them to the Microsoft.TemplateEngine.Cli, as it defines an interface that is using HelpContext and is being used by the other projects that customize help. That was quite straightforward, all I needed was to update the license header, namespaces and fix some code analysis issues like leading whitespace etc.

Context: dotnet/command-line-api#2563

…ption that is being used by many commands, just create a dedicated copy for each of them
@adamsitnik adamsitnik self-assigned this May 28, 2025
@adamsitnik adamsitnik force-pushed the sclHelpIsInternal branch from 77f255f to 0bbd5dc Compare May 28, 2025 15:16
@adamsitnik adamsitnik force-pushed the sclHelpIsInternal branch from 0bbd5dc to d955427 Compare May 28, 2025 15:24
@adamsitnik adamsitnik changed the title stop using System.CommandLine types that won't be public anymore reduce the need of customizing Help output May 28, 2025
@adamsitnik adamsitnik marked this pull request as ready for review May 28, 2025 15:44
@adamsitnik adamsitnik requested a review from baronfel May 28, 2025 15:46
@adamsitnik adamsitnik requested a review from a team as a code owner May 29, 2025 16:30
/// </summary>
internal static class LocalizationResources
{
private static Lazy<ResourceManager> _resourceManager = new(
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not something new, rather a re-use of a workaround from the past:

private static Lazy<ResourceManager> _resourceManager = new(
() => new ResourceManager("System.CommandLine.Properties.Resources", typeof(System.CommandLine.Symbol).Assembly));

@adamsitnik adamsitnik changed the title reduce the need of customizing Help output stop using System.CommandLine types that aren't public anymore May 29, 2025
@adamsitnik adamsitnik requested a review from MiYanni May 30, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants