You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AbsoluteDirectoryPath.Parent and GetAncestors() ignore "." and ".." segments: parent of "/home/user/.." is "/home/user" #446
AbsoluteDirectoryPath.Parent (Semantics.Paths/Implementations/AbsoluteDirectoryPath.cs, about lines 45-63) computes Path.GetDirectoryName(WeakString) on the raw string. GetAncestors() (about line 230) is built on Parent.
SemanticPath.MakeCanonical only normalises separators and trailing slashes, and IsAbsolutePathAttribute accepts . and .. segments. So a dot segment is treated as an ordinary directory name. IsChildOf in the same file already resolves with Path.GetFullPath, so the type is internally inconsistent.
This is the absolute-path twin of #387, which PR #423 fixed only for RelativeDirectoryPath: it calls Normalize() before taking the parent.
Reproduction (net10.0)
varp=AbsoluteDirectoryPath.Create<AbsoluteDirectoryPath>("/home/user/..");p.Parent;// "/home/user" expected "/" (p names /home)p.GetAncestors();// /home/user, /home, / (first "ancestor" is a child of p itself)AbsoluteDirectoryPath.Create<AbsoluteDirectoryPath>("/home/user/.").Parent;// "/home/user", expected "/home"
Code that walks upward with GetAncestors() visits the wrong directories. Typical cases are looking for a config file or repo root, or a containment check.
Suggested fix
In Parent, resolve first: Path.GetDirectoryName(Path.GetFullPath(WeakString)). On netstandard2.0, use the existing PathPolyfill.
Keep the rule that a root returns itself.
Acceptance criteria
Parent and GetAncestors() give the resolved parent chain for inputs containing . and .., on both Windows-style and Unix-style paths.
Tests are added alongside Semantics.Test/Paths/AbsoluteDirectoryPathParentTests.cs.
Priority: Medium. Parent and GetAncestors() return the wrong directories for paths containing . or ... That misleads upward searches and containment checks, and it is inconsistent with IsChildOf in the same type. The fix is to resolve the path with Path.GetFullPath first, using the existing polyfill on netstandard2.0.
Area / suggested assignment: Semantics.Paths AbsoluteDirectoryPath.Parent / GetAncestors().
Activity
matt-edmondson commentedon Oct 18, 2026
Triage
ParentandGetAncestors()return the wrong directories for paths containing.or... That misleads upward searches and containment checks, and it is inconsistent withIsChildOfin the same type. The fix is to resolve the path withPath.GetFullPathfirst, using the existing polyfill on netstandard2.0.AbsoluteDirectoryPath.Parent/GetAncestors()...and.: the "parent" of..is""and the parent ofa/..isa, a child of the path itself #387, which PR Resolve . and .. before taking a relative directory's parent [patch] #423 fixed only forRelativeDirectoryPath. Not a duplicate.Generated by Claude Code