-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add GetCanonicalForm to the AbsolutePath API #13088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 adds a GetFullPath() method to the AbsolutePath struct to provide an API that fully replicates Path.GetFullPath behavior, including resolving relative path segments ("." and "..") and normalizing directory separators on Windows. This enables replacing direct Path.GetFullPath calls in task code with a more controlled API.
Changes:
- Added
GetFullPath()method with optimization to avoid allocations when no normalization is needed - Added comprehensive unit tests for both Windows and Unix platforms
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Framework/PathHelpers/AbsolutePath.cs | Implements GetFullPath() with detection logic for relative segments and separator normalization needs |
| src/Framework.UnitTests/AbsolutePath_Tests.cs | Adds test cases for null paths, Windows path normalization, and Unix path normalization |
f1d94ca to
d9b4d89
Compare
JanProvaznik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this pr also use this new method on the already migrated tasks where needed?
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Context
It is quite often that
Path.GetFullPathis used in the tasks code. For enlightening we would want to replace it with our own API. The candidate wasTaskEnvironment.GetAbsolutePathfor replacing.However, they do not do the same set of actions.
TaskEnvironment.GetAbsolutePathonly absolutizes the path but does not resolve possible "." and ".." in the path or normalize path separators on Windows.For some scenarios this is critical, for some that does not matter. We should provide an option for fully copy
Path.GetFullPathbehaviorChanges Made
AbsolutePath.GetCanonicalForm()Testing
Added unit tests