Skip to content

Conversation

@adityapatwardhan
Copy link
Member

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

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

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.

  • Yes
  • No

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.

  • High
  • Medium
  • Low

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.

Copilot AI review requested due to automatic review settings December 4, 2025 18:10
@adityapatwardhan adityapatwardhan added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Dec 4, 2025
@adityapatwardhan adityapatwardhan enabled auto-merge (squash) December 4, 2025 18:17
Copy link
Contributor

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 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.cs to 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
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Inconsistent parameter capitalization: -force should be -Force to match the capitalization used in line 160 and PowerShell conventions.

Suggested change
Set-Alias -Name tma -Value Test-MyAlias -force
Set-Alias -Name tma -Value Test-MyAlias -Force

Copilot uses AI. Check for mistakes.
@adityapatwardhan adityapatwardhan merged commit 6827de5 into PowerShell:release/v7.6 Dec 4, 2025
38 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants