Skip to content

Rename Resolve-Path -RelativeBasePath parameter to -BasePath - #28380

Open
soroshsabz wants to merge 2 commits into
PowerShell:masterfrom
soroshsabz:feature/resolve-path-basepath
Open

soroshsabz wants to merge 2 commits into
PowerShell:masterfrom
soroshsabz:feature/resolve-path-basepath

Conversation

@soroshsabz

@soroshsabz soroshsabz commented Nov 8, 2026 •

Copy link
Copy Markdown

PR Summary

This PR renames the Resolve-Path parameter -RelativeBasePath to -BasePath, based on issue

-RelativeBasePath is kept as a parameter alias, so existing scripts continue to work unchanged.

-BasePath is a better name because:

This means both of these now read naturally:

# With -Relative
# Get the relative path from C:\Windows to, say, C:\Users\jdoe -> '..\Users\jdoe'
Resolve-Path $HOME -Relative -BasePath C:\Windows

# Without -Relative:
# Get the absolute paths of items named Prog* in C:\
Resolve-Path Prog* -BasePath C:\

The change also updates the engine's path completion helper
(CompletionCompleters.cs), which binds this parameter programmatically when
completing using module/using assembly paths, and updates the
Resolve-Path tests to use the new parameter name - including a new test that
verifies the -RelativeBasePath alias still works. The corresponding
documentation update is in MicrosoftDocs/PowerShell-Docs#13380.

To preserve source and binary compatibility for consumers that access the
cmdlet object directly (for example, C# hosting code that sets
ResolvePathCommand.RelativeBasePath), the public
ResolvePathCommand.RelativeBasePath property is retained as a non-parameter
property that forwards to BasePath.

Confirmed locally that the rename behaves as expected (built from this PR and ran the tests below) with the following:

$null = New-Item -ItemType Directory -Path (Join-Path $d 'sub')
Set-Content (Join-Path $d 'sub\file.txt') 'x'

(Resolve-Path -Path sub\file.txt -BasePath $d).Path                       # C:\...\sub\file.txt
Resolve-Path -Path sub\file.txt -BasePath $d -Relative                    # .\sub\file.txt
(Resolve-Path -Path sub\file.txt -RelativeBasePath $d).Path               # alias: same as -BasePath
Resolve-Path -Path sub\file.txt -RelativeBasePath $d -Relative            # alias: .\sub\file.txt
(Get-Command Resolve-Path).Parameters['BasePath'].Aliases                 # RelativeBasePath

Note: build.psm1 intentionally keeps using -RelativeBasePath, so it keeps working when run under PowerShell 7.4+ hosts where only the original parameter name exists.

PR Context

Fixes #20937

Notes

Tests

All existing Resolve-Path.Tests.ps1 tests were updated to use -BasePath, and a new test verifies that the -RelativeBasePath alias continues to work and behave identically (including the internal code path that resolves relative paths against the base path).

All 20 tests in test\powershell\Modules\Microsoft.PowerShell.Management\Resolve-Path.Tests.ps1 pass against a local build of this PR:

Total: 20  Passed: 20  Failed: 0  Skipped: 0

Breaking Changes & Documentation

This is not a breaking change: -RelativeBasePath remains usable as a parameter alias. The Resolve-Path cmdlet reference documentation has been updated to document -BasePath (with -RelativeBasePath as an alias):

PR Checklist

The name `-BasePath` is clearer: it does not suggest that the parameter
only applies together with the `-Relative` switch (and it no longer
tempts users to expect that specifying it implies `-Relative`,
see issue PowerShell#20920). `-RelativeBasePath` is kept as a parameter alias so
existing scripts continue to work.

Also updates the engine's path completion helper, which binds this
parameter programmatically, and updates the Resolve-Path tests to use
the new parameter name, including a test verifying that the
`-RelativeBasePath` alias still works.

Fix PowerShell#20937
@soroshsabz
soroshsabz requested a review from a team as a code owner November 8, 2026 20:55
Copilot AI balanced review requested due to automatic review settings November 8, 2026 20:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Removing the public RelativeBasePath property breaks source and binary compatibility for direct callers; a non-parameter forwarding property is needed to preserve the existing API.

1 open issue
What changed in this PR

Renames Resolve-Path -RelativeBasePath to -BasePath to clarify that it works with or without -Relative, addressing #20937.

Changes:

  • Introduces -BasePath, retaining -RelativeBasePath as a parameter alias.
  • Updates path completion to bind the new parameter name.
  • Updates existing tests and adds an alias-equivalence test.
File Description
test/​powershell/​Modules/​Microsoft.PowerShell.Management/​Resolve-Path.Tests.ps1 Uses -BasePath and adds alias coverage.
src/​System.Management.Automation/​engine/​CommandCompletion/​CompletionCompleters.cs Uses BasePath for module and assembly path completion.
src/​Microsoft.PowerShell.Commands.Management/​commands/​management/​ResolvePathCommand.cs Renames the parameter and internal references, adding the original name as an alias.

Review effort: Balanced

The Copilot review on the PR pointed out that removing the public
`ResolvePathCommand.RelativeBasePath` property breaks source and binary
compatibility for callers that access the cmdlet object directly.

Retain it as a non-parameter property that forwards to `BasePath`, so the
public API is preserved while `-BasePath` remains the parameter name (with
`-RelativeBasePath` kept as a parameter alias for command-line compatibility).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Resolve-Path parameter rename and compatibility-preserving updates.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

Resolve-Path: Rename -RelativeBasePath to -BasePath

2 participants