Repository navigation
Rename Resolve-Path -RelativeBasePath parameter to -BasePath - #28380
Open
soroshsabz wants to merge 2 commits into
Open
soroshsabz wants to merge 2 commits into
soroshsabz wants to merge 2 commits into
Conversation
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
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 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-RelativeBasePathas 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).
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.

PR Summary
This PR renames the
Resolve-Pathparameter-RelativeBasePathto-BasePath, based on issueResolve-Path: Rename-RelativeBasePathto-BasePath#20937-RelativeBasePathis kept as a parameter alias, so existing scripts continue to work unchanged.-BasePathis a better name because:-Relativeswitch.-Relative- seeResolve-Path -RelativeBasePathis ignored unless-Relativeis also specified, should imply the latter #20920.This means both of these now read naturally:
The change also updates the engine's path completion helper
(
CompletionCompleters.cs), which binds this parameter programmatically whencompleting
using module/using assemblypaths, and updates theResolve-Pathtests to use the new parameter name - including a new test thatverifies the
-RelativeBasePathalias still works. The correspondingdocumentation 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 publicResolvePathCommand.RelativeBasePathproperty is retained as a non-parameterproperty that forwards to
BasePath.Confirmed locally that the rename behaves as expected (built from this PR and ran the tests below) with the following:
Note:
build.psm1intentionally 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.ps1tests were updated to use-BasePath, and a new test verifies that the-RelativeBasePathalias 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.ps1pass against a local build of this PR:Breaking Changes & Documentation
This is not a breaking change:
-RelativeBasePathremains usable as a parameter alias. TheResolve-Pathcmdlet reference documentation has been updated to document-BasePath(with-RelativeBasePathas an alias):-BasePathparameter (formerly-RelativeBasePath) of Resolve-Path MicrosoftDocs/PowerShell-Docs#13379PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header-BasePathparameter (formerly-RelativeBasePath) of Resolve-Path MicrosoftDocs/PowerShell-Docs#13379