Repository navigation
Resolve . and .. before taking a relative directory's parent [patch] - #423
Merged
Merged
Conversation
RelativeDirectoryPath.Parent stripped the last segment of the text with Path.GetDirectoryName, so the "parent" of `..` was "", of `a/..` was `a` and of `.` was "": a child of the path, or the path itself. Parent now normalizes lexically first, drops the last named segment, and climbs one more level when the path only names the start directory or above it. Fixes #387 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NAMc9xXW1LFVHGFLp4SN2n
|
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 #387
Problem
RelativeDirectoryPath.ParentusedPath.GetDirectoryName, which strips the last segment as text and does not know what.or..mean. For paths ending in either,Parentnamed a child of the path or the path itself:Parent.."".""a/..aAs a result, an upward walk built on
Parentcould move downward or loop forever.Change
Parentnow:..-preservingNormalizefrom RelativeDirectoryPath.Normalize() drops leading "..": "../sibling" becomes "sibling", so the path points somewhere else #288,..when there is nothing to drop, either because the path is empty or., or because it consists only of..segments.Parent..../..../..../../.../""..a/....a""(unchanged)a/ba(unchanged)Behaviour change to note:
Parentof the empty path is now..instead of"". The empty path names the starting directory, so""claimed to be its own parent. This is what the issue's "append.." rule asks for, and it keeps the property below true. No code in this repository walksRelativeDirectoryPath.Parent. The only upward walk is onAbsoluteDirectoryPath, which is unaffected.Tests
In
RelativePathPropertyTests:RelativeDirectoryPath_Parent_ResolvesDotSegmentsis a table test covering the acceptance criteria, plusa/../..,../aanda/./b.RelativeDirectoryPath_Parent_AgreesWithAbsoluteParentchecks thatp.Parent.AsAbsolute(b) == p.AsAbsolute(b).Parentfor the same ten paths.Verification
Semantics.Pathsbuilds for every target framework, netstandard2.0 included, with 0 warnings.Semantics.Testsuite passes on net10.0: 1638 passed, 8 skipped.#422 (empty left operand to
/) touches neighbouring behaviour but different code. The two PRs are independent of each other.🤖 Generated with Claude Code
https://claude.ai/code/session_01NAMc9xXW1LFVHGFLp4SN2n
Generated by Claude Code