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
DirectoryPath.Parent still treats . and .. as directory names: the parent of /home/user/.. is /home/user, and the parent of .. is "" #478
SemanticPath.MakeCanonical only normalises separators and trailing slashes, so . and .. segments survive and are dropped as if they were ordinary names.
The same bug was already fixed for RelativeDirectoryPath in #387, which normalises first, and for AbsoluteDirectoryPath in #446, which resolves with Path.GetFullPath first. Neither fix covers the polymorphic DirectoryPath primitive. That primitive is also the type returned by SemanticFilePath.DirectoryPath and by the default SemanticDirectoryPath.GetContents().
Reproduction (net10.0, Linux, observed)
DirectoryPath.Create<DirectoryPath>("/home/user/..").Parent;// "/home/user" expected "/" (the path names /home)DirectoryPath.Create<DirectoryPath>("/home/user/.").Parent;// "/home/user" expected "/home"DirectoryPath.Create<DirectoryPath>("a/..").Parent;// "a" expected ".." (currently a child of the path itself)DirectoryPath.Create<DirectoryPath>("..").Parent;// "" expected "../.."DirectoryPath.Create<DirectoryPath>("a/./b").Parent;// "a/." expected "a"
Code that walks upwards from a DirectoryPath visits the wrong directories. For a/.. it moves down into a.
Suggested fix
Branch on whether the path is rooted:
rooted: resolve it, as AbsoluteDirectoryPath.Parent now does;
relative: normalise lexically and drop or append .., as RelativeDirectoryPath.ComputeParent does.
Ideally, delegate to those two implementations so the three cannot drift apart again.
Keep the documented "empty path for a root" behaviour, or align it with AbsoluteDirectoryPath, but document whichever is chosen.
Acceptance criteria
All five inputs above return the resolved parent.
Tests sit next to Semantics.Test/Paths/AbsoluteDirectoryPathParentTests.cs.
Priority: Medium. An upward walk from a DirectoryPath visits the wrong directories, and for a/.. it walks down. It doesn't hang or lose data, but SemanticFilePath.DirectoryPath and GetContents() return this type, so it is easy to hit.
Area / suggested assignee:Semantics.Paths/Primitives/DirectoryPath.csParent. Owner: @matt-edmondson
Next step: branch on rootedness and delegate to the AbsoluteDirectoryPath / RelativeDirectoryPath.ComputeParent logic so the three implementations can't drift apart. Document the root behaviour you pick, and add the five repro cases as tests.
Activity
matt-edmondson commentedon Oct 20, 2026
Triage
DirectoryPathvisits the wrong directories, and fora/..it walks down. It doesn't hang or lose data, butSemanticFilePath.DirectoryPathandGetContents()return this type, so it is easy to hit.Semantics.Paths/Primitives/DirectoryPath.csParent. Owner: @matt-edmondson..and.: the "parent" of..is""and the parent ofa/..isa, a child of the path itself #387 (relative) and AbsoluteDirectoryPath.Parent and GetAncestors() ignore "." and ".." segments: parent of "/home/user/.." is "/home/user" #446 (absolute), and related to AbsoluteDirectoryPath.IsRoot is false for /home/.. while Parent returns the path itself, so while (!dir.IsRoot) dir = dir.Parent never ends #479 (IsRootvs resolvedParent). Doing both together is suggested. No open PR covers it.AbsoluteDirectoryPath/RelativeDirectoryPath.ComputeParentlogic so the three implementations can't drift apart. Document the root behaviour you pick, and add the five repro cases as tests.Generated by Claude Code