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.Name and DirectoryPath.Name return FileName, so dir.Parent / dir.Name builds a file path #498
The / operator picks its result type from the right operand. AbsoluteDirectoryPath / DirectoryName gives an AbsoluteDirectoryPath (line 185), and AbsoluteDirectoryPath / FileName gives an AbsoluteFilePath (line 201). DirectoryPath works the same way at lines 115 and 131. So rebuilding a directory from its own parts changes its kind:
vardir=AbsoluteDirectoryPath.Create<AbsoluteDirectoryPath>("/home/user/docs");varrebuilt=dir.Parent/dir.Name;// AbsoluteFilePath "/home/user/docs"AbsoluteDirectoryPathd2=dir.Parent/dir.Name;// CS0029: no implicit conversion
For RelativeDirectoryPath, the same expression stays a directory.
Why it matters
The library's purpose is to keep "file" and "directory" apart in the type system. Here a directory's own name walks it into the file side, and callers have to round-trip through WeakString to get back. Walking up and rebuilding a tree, or mapping a directory into another root (otherRoot / dir.Name), is exactly where this goes wrong.
Suggested fix / acceptance criteria
AbsoluteDirectoryPath.Name and DirectoryPath.Name return DirectoryName, matching RelativeDirectoryPath. This changes the public API, so add a CompatibilitySuppressions.xml entry and a migration-guide note.
For every directory type, dir.Parent / dir.Name has the same type as dir. Add a test for each.
The documented "as written, not as resolved" behaviour for .. / . names stays unchanged.
Activity