Skip to content

Conversation

@AR-May
Copy link
Member

@AR-May AR-May commented Jan 22, 2026

Context

It is quite often that Path.GetFullPath is used in the tasks code. For enlightening we would want to replace it with our own API. The candidate was TaskEnvironment.GetAbsolutePath for replacing.

However, they do not do the same set of actions. TaskEnvironment.GetAbsolutePath only 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.GetFullPath behavior

Changes Made

  • Added AbsolutePath.GetCanonicalForm()

Testing

Added unit tests

@AR-May AR-May marked this pull request as ready for review January 22, 2026 13:52
Copilot AI review requested due to automatic review settings January 22, 2026 13:52
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 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

@AR-May AR-May force-pushed the update-absolute-path-api branch from f1d94ca to d9b4d89 Compare January 28, 2026 12:26
Copy link
Member

@JanProvaznik JanProvaznik left a 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?

@AR-May AR-May changed the title Add GetFullPath to the AbsolutePath API Add GetCanonicalForm to the AbsolutePath API Jan 28, 2026
@AR-May AR-May self-assigned this Jan 28, 2026
@AR-May
Copy link
Member Author

AR-May commented Jan 28, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AR-May
Copy link
Member Author

AR-May commented Jan 29, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants