Skip to content

Expose AbsolutePath.GetCanonicalForm() - #14873

Merged
JanProvaznik merged 5 commits into
mainfrom
copilot/expose-getcanonicalpath-api
Aug 31, 2026
Merged

JanProvaznik merged 5 commits into
mainfrom
copilot/expose-getcanonicalpath-api

Conversation

Copilot AI commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Work item (Internal use):

Summary

Exposes AbsolutePath.GetCanonicalForm() to external task authors without changing its behavior.

  • Promotes the existing method from internal to public.
  • Documents canonicalization guidance for multithreaded tasks.
  • Adds public-surface coverage.
AbsolutePath path = TaskEnvironment.GetAbsolutePath(input);
AbsolutePath canonicalPath = path.GetCanonicalForm();

Customer Impact

External tasks can canonicalize task-relative paths without using process-dependent path resolution.

Regression?

No. This is an additive API change with unchanged implementation.

Testing

N/A

Risk

Low. Existing callers and canonicalization semantics are unchanged.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo.

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Copilot AI changed the title [WIP] Expose GetCanonicalPath API for external use Expose AbsolutePath.GetCanonicalForm() Aug 28, 2026
Copilot AI requested a review from JanProvaznik August 28, 2026 12:59
@JanProvaznik
JanProvaznik marked this pull request as ready for review August 28, 2026 13:01
@JanProvaznik
JanProvaznik requested review from AR-May, baronfel and rainersigwald and a lite review from Copilot August 28, 2026 13:01

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.

Pull request overview

This PR exposes Microsoft.Build.Framework.AbsolutePath.GetCanonicalForm() as a public API for external task authors, keeping the existing canonicalization behavior unchanged while updating guidance and adding a small public-surface verification test.

Changes:

  • Promotes AbsolutePath.GetCanonicalForm() from internal to public in Microsoft.Build.Framework.
  • Adds a unit test asserting the method is discoverable as a public instance API.
  • Updates the multithreaded task spec to mention GetCanonicalForm() and explain when to use it during migration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Framework/PathHelpers/AbsolutePath.cs Changes GetCanonicalForm() accessibility to public with existing implementation and docs retained.
src/Framework.UnitTests/AbsolutePath_Tests.cs Adds a reflection-based test to ensure the API is public.
documentation/specs/multithreading/thread-safe-tasks.md Documents the new public API and provides canonicalization guidance (but contains sample inaccuracies noted in comments).
Suppressed comments (1)

documentation/specs/multithreading/thread-safe-tasks.md:162

  • The usage example calls path.Path, but AbsolutePath doesn’t expose a Path property (it has Value and an implicit conversion to string). As written, this sample won’t compile and may confuse task authors; use path.Value (or just path).
`AbsolutePath` converts implicitly to string for seamless integration with existing File/Directory APIs.
`GetCanonicalForm()` applies `Path.GetFullPath()` canonicalization to an already rooted path, resolving `.` and `..` segments and normalizing directory separators. Use it when migrating code that previously relied on `Path.GetFullPath()`; `TaskEnvironment.GetAbsolutePath()` roots paths but intentionally does not canonicalize them.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
@JanProvaznik
JanProvaznik merged commit 595f954 into main Aug 31, 2026
10 checks passed
@JanProvaznik
JanProvaznik deleted the copilot/expose-getcanonicalpath-api branch August 31, 2026 12:09
This was referenced Nov 15, 2026
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.

Expose AbsolutePath.GetCanonicalForm()

5 participants