Repository navigation
Only strip .exe/.dll when computing RootCommand.ExecutableName - #2855
Merged
adamsitnik merged 2 commits intoOct 12, 2026
Merged
Conversation
On .NET 11, Environment.GetCommandLineArgs()[0] is the extensionless apphost name on Linux/macOS, so Path.GetFileNameWithoutExtension truncated dotted names (Contoso.Tool -> Contoso). Strip only known host extensions. Fixes dotnet#2850 Co-authored-by: Copilot <[email protected]> Copilot-Session: 3b277dd7-ee88-4838-8f41-724305913c08
There was a problem hiding this comment.
🟡 Changes recommended
The public XML documentation still describes the previous extension-removal behavior.
1 open finding
What changed in this PR
Updates executable-name resolution for .NET 11 apphosts while preserving dotted names.
Changes:
- Strips only
.exeand.dllsuffixes. - Uses span-based processing on modern .NET.
- Adds cross-platform unit coverage.
| File | Description |
|---|---|
RootCommand.cs |
Uses the new executable-name helper. |
ExecutableNameHelper.cs |
Implements selective extension removal. |
System.CommandLine.Tests.csproj |
Links the helper into tests. |
RootCommandTests.cs |
Tests dotted names, extensions, casing, and spaces. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <[email protected]> Copilot-Session: 3b277dd7-ee88-4838-8f41-724305913c08
adamsitnik
enabled auto-merge (squash)
October 12, 2026 09:40
jeffhandley
approved these changes
Oct 12, 2026
Member
Author
|
@mmitche I need to backport this PR to .NET 11 RTM. Which branch should I use? release/11.0? Or are you going to create release/11.0-rtm? |
7 of 16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Starting with .NET 11 (dotnet/runtime#131671),
Environment.GetCommandLineArgs()[0]is the name the apphost was invoked with. On Linux/macOS the apphost has no extension, soPath.GetFileNameWithoutExtensiontruncated dotted names (Contoso.Tool->Contoso).Only the known host extensions (
.exe/.dll) are now stripped. The helper uses a span-based path on modern .NET to reduce allocations. Added unit tests.Fixes #2850