Skip to content

Enhance path normalization: add handling for consecutive directory separators#13369

Merged
tommcdon merged 3 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/handleConsecutivePathSeparators
Mar 16, 2026
Merged

Enhance path normalization: add handling for consecutive directory separators#13369
tommcdon merged 3 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/handleConsecutivePathSeparators

Conversation

@tommcdon
Copy link
Copy Markdown
Member

@tommcdon tommcdon commented Mar 11, 2026

Investigation from VS feedback item https://developercommunity.visualstudio.com/t/MSIX-Deployed-App-Fails-to-Find-Resource/11049946 led to finding of this issue

Context

AssignTargetPath task in VS 18 Preview build to new code path gated behind ChangeWaves.Wave18_5 that uses AbsolutePath.GetCanonicalForm() instead of the previous Path.GetFullPath() for path normalization. GetCanonicalForm() doesn't normalize consecutive directory separators (\\\), unlike Path.GetFullPath() which did. This resulted in a "flattening" of the TargetPath, breaking the a Visual Studio deployment scenario.

Regression was introduced on #13069.

Changes Made

AbsolutePath.GetCanonicalForm() has a fast-path optimization that skips calling Path.GetFullPath() when the path has no relative segments (/. or .) and no mixed separators (/ on Windows). However, it didn't check for consecutive directory separators (e.g., \), so paths like ...win-x64\ were returned unchanged. The fix adds a check for consecutive separators (\ on Windows, // on Unix) so they fall through to Path.GetFullPath() which normalizes them to a single separator.

Testing

Added the appropriate unit tests. Also validated the originally reported issue in the VS feedback ticket by patching binaries in VS.

@tommcdon tommcdon self-assigned this Mar 11, 2026
@tommcdon tommcdon marked this pull request as ready for review March 11, 2026 23:12
Copilot AI review requested due to automatic review settings March 11, 2026 23:12
Copy link
Copy Markdown
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 fixes a regression in AbsolutePath.GetCanonicalForm() where its fast path could return Windows/Unix paths containing consecutive directory separators without collapsing them, diverging from Path.GetFullPath() behavior and impacting VS deployment scenarios.

Changes:

  • Extend the GetCanonicalForm() fast-path gate to detect consecutive directory separators and fall back to Path.GetFullPath() when present.
  • Add unit test cases covering consecutive separators on both Windows and Unix paths.

Reviewed changes

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

File Description
src/Framework/PathHelpers/AbsolutePath.cs Adds detection of consecutive separators to ensure canonicalization matches Path.GetFullPath() semantics.
src/Framework.UnitTests/AbsolutePath_Tests.cs Adds coverage for consecutive separator inputs on Windows and Unix.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
@tommcdon tommcdon requested a review from rainersigwald March 11, 2026 23:14
Comment thread src/Framework/PathHelpers/AbsolutePath.cs Outdated
Copy link
Copy Markdown
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tommcdon!

@JanProvaznik/@AR-May I'll let y'all figure out whether to rebase/retarget this to the servicing branch or backport.

@tommcdon tommcdon enabled auto-merge March 13, 2026 16:00
@tommcdon
Copy link
Copy Markdown
Member Author

@JanProvaznik / @AR-May - just FYI, the PR is ready for your approval. Please let me know if anything else is needed.

@tommcdon
Copy link
Copy Markdown
Member Author

@JanProvaznik @AR-May - friendly ping for your approval on the PR

@AR-May
Copy link
Copy Markdown
Member

AR-May commented Mar 16, 2026

@JanProvaznik @AR-May - friendly ping for your approval on the PR

Hi! I placed the whole optimization under a change wave as we decided offline. With it, it should be good to go to the main. In 18.5 branch, we will be most conservative - we will remove the optimization altogether for a fix.

@tommcdon tommcdon merged commit 72d89ab into dotnet:main Mar 16, 2026
10 checks passed
@tommcdon tommcdon deleted the dev/tommcdon/handleConsecutivePathSeparators branch March 16, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants