[release/v7.6] Properly Expand Aliases to their actual ResolvedCommand#26571
Conversation
There was a problem hiding this comment.
Pull request overview
This PR backports a fix from #25763 that resolves a long-standing issue with how aliases display their resolved command names. Previously, the DisplayName property would only show the "AliasName -> ResolvedCommand" format for aliases containing a hyphen, while other aliases would show just their name. This change removes that conditional logic so that all aliases consistently display their resolved command mapping.
Key Changes
- Simplified the DisplayName script property logic in
TypeTable_Types_Ps1Xml.csto remove the hyphen check that was preventing proper display of all alias resolutions - Added comprehensive test coverage to verify that DisplayName always shows "AliasName -> ResolvedCommand" format for all aliases, including chained alias scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs |
Removed conditional logic checking for hyphens in alias names, allowing all aliases to show resolved command mapping in DisplayName property |
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Alias.Tests.ps1 |
Added test case verifying DisplayName format for both direct aliases and chained aliases (alias to alias), with proper cleanup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| It "Get-Alias DisplayName should always show AliasName -> ResolvedCommand for all aliases" { | ||
| Set-Alias -Name Test-MyAlias -Value Get-Command -Force | ||
| Set-Alias -Name tma -Value Test-MyAlias -force |
There was a problem hiding this comment.
Inconsistent parameter capitalization: -force should be -Force to match the capitalization used in line 160 and PowerShell conventions.
| Set-Alias -Name tma -Value Test-MyAlias -force | |
| Set-Alias -Name tma -Value Test-MyAlias -Force |
6827de5
into
PowerShell:release/v7.6
Backport of #25763 to release/v7.6
Triggered by @adityapatwardhan on behalf of @kilasuit
Original CL Label: CL-Engine
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Customer Impact
This fixes a long-standing quirk in how aliased commands display their resolved command names. The change improves user experience by consistently showing alias -> resolved command mapping for better discoverability. This is an engine improvement that affects how Get-Alias displays command information.
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Original PR added comprehensive tests in Get-Alias.Tests.ps1 to verify that DisplayName always shows the correct "AliasName -> ResolvedCommand" format for all aliases. The fix was verified to resolve issue #25616.
Risk
REQUIRED: Check exactly one box.
This is a display/formatting improvement in the engine's alias system with comprehensive test coverage. The change is isolated to the DisplayName script property logic and doesn't affect core command execution or critical functionality.