Match path containment case to the platform and accept paths directly under a root [patch] - #296
Merged
Merged
Conversation
… under a root [patch] IsChildOf/IsParentOf compared prefixes case-insensitively on every platform, so on Linux /home/user/DOCS/report was reported as inside /home/user/docs. They also required a separator after the parent, which a root already ends in, so /home was not a child of /. Both types now share one rule: ordinal-ignore-case on Windows, ordinal elsewhere (macOS included), and a parent ending in a separator contains every longer path that starts with it. Fixes #291 Fixes #282 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PHrrj7bWzA48Gf3akqi476
|
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #291
Fixes #282
Both issues are in the same prefix check, and both triage notes asked for them to be fixed together, so this is one PR.
What was wrong
AbsoluteDirectoryPath.IsChildOfandAbsoluteFilePath.IsChildOfcompared prefixes withOrdinalIgnoreCaseon every platform. On Linux,/home/user/DOCS/reportwas reported as inside its sibling/home/user/docs, which defeatsIsChildOfwhen it is used as a sandbox or output-directory guard. The "same path" branch also disagreed with the prefix branch: it was case-sensitive on the span targets and case-insensitive on netstandard2.0./,C:\) already ends in one, so/home,/etc.txt, and even/home/userwere not children of/, althoughhome.Parentis/.Change
PathContainmenthelper, used byAbsoluteDirectoryPath.IsChildOf(and soIsParentOf) andAbsoluteFilePath.IsChildOf. This replaces three copies of the check, including the separate netstandard2.0 branch.OrdinalIgnoreCaseon Windows,Ordinaleverywhere else. The triage asked for an explicit decision on macOS: I choseOrdinal, the same comparison that path equality and hashing already use. APFS is case-insensitive by default but can be formatted case-sensitive, and ordinal is the choice that can't report a sibling as a child. The reasoning is written down in the helper's remarks./home2is not inside/home.Tests
New
PathContainmentTests, built fromTestPathsso they run on every platform:IsParentOfis checked too.home.Parent == rootis checked alongside.home2,home2/user, andhome2.txtare not children ofhome.Before the fix, 5 of the 8 tests failed on Linux: both case tests, and all three root tests. With the fix, the full
Semantics.Testsuite passes (1344 passed, 8 skipped), andSemantics.Pathsbuilds for all five targets with no warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01PHrrj7bWzA48Gf3akqi476
Generated by Claude Code