Repository navigation
Expose AbsolutePath.GetCanonicalForm() - #14873
Conversation
|
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>
There was a problem hiding this comment.
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()frominternaltopublicinMicrosoft.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, butAbsolutePathdoesn’t expose aPathproperty (it hasValueand an implicit conversion tostring). As written, this sample won’t compile and may confuse task authors; usepath.Value(or justpath).
`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>
Work item (Internal use):
Summary
Exposes
AbsolutePath.GetCanonicalForm()to external task authors without changing its behavior.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.