Repository navigation
Resolve dot segments in AbsoluteDirectoryPath.Parent and GetAncestors [patch] - #453
Merged
Merged
Conversation
AbsoluteDirectoryPath.Parent called Path.GetDirectoryName on the raw text, so "." and ".." were treated as ordinary directory names: the parent of /home/user/.. was /home/user, a child of the path itself, and GetAncestors, built on Parent, walked the wrong chain. IsChildOf in the same type already resolves with Path.GetFullPath. Parent now resolves the path the same way before dropping the last segment. A root is still its own parent. Fixes #446 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TUnnjk1kZxBU7o2kbNsSaP
|
This was referenced Oct 18, 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 #446
Summary
Before:
AbsoluteDirectoryPath.ParentcalledPath.GetDirectoryNameon the raw text, so.and..were treated as ordinary directory names. The parent of/home/user/..came back as/home/user, a child of the path itself.GetAncestors()is built onParent, so it walked the wrong chain too.After:
Parentresolves the path withPath.GetFullPathbefore dropping the last segment, the same resolutionIsChildOfin this type already uses. A root is still its own parent.Path.GetFullPathexists on every target, andPathPolyfillalready calls it on netstandard2.0. This is the absolute-path counterpart of theRelativeDirectoryPathfix in #423.Tests
AbsoluteDirectoryPathParentTests.Parent_ResolvesDotSegmentschecks<root>Users/user/..→ root,…/user/.→<root>Users,…/Documents/../.→<root>Users, and…/user/../user/Documents→<root>Users/user. The tests build paths withTestPaths, so they run with Windows or Unix separators to match the host.AbsoluteDirectoryPathParentTests.GetAncestors_ResolvesDotSegmentschecks that the ancestors of…/Documents/..are[<root>Users, <root>].AbsoluteDirectoryPath.cschange reverted, both new tests fail. With it in place, the fullSemantics.Testsuite passes on net10.0 (1701 total: 1693 passed, 8 skipped), andSemantics.Pathsbuilds for netstandard2.0 with no warnings.Generated by Claude Code