Repository navigation
Name the starting directory "." in Parent and a bare file's directory [patch] - #504
Merged
Merged
Conversation
RelativeDirectoryPath.Parent of a single-segment path, and the directory of a bare file name (RelativeFilePath.RelativeDirectoryPath and SemanticFilePath.DirectoryPath), were the empty path. Path.GetFullPath rejects that, so AsAbsolute() threw, and Directory.Exists reads it as missing, so IsDirectory was false. They are now ".", matching Normalize. CombinePaths drops a leading "." the way it already drops "", so dir.Parent / dir.Name still gives back "a" rather than "./a". PathPolyfill.GetFullPath on netstandard2.0 resolves an empty path to the base path, as the BCL overload does on newer frameworks. Fixes #502 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2PeSdxz6omjxYwwT4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2PeSdxz6omjxYwwT4
|
This was referenced Oct 30, 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 #502
What was wrong
Three getters returned the empty path to mean "the starting directory":
RelativeDirectoryPath.Parentfor a single-segment pathRelativeFilePath.RelativeDirectoryPathfor a bare file nameSemanticFilePath.DirectoryPathfor a bare file nameThe BCL rejects or misreads the empty path.
Path.GetFullPath("")throws, soAsAbsolute()threw for any file in the current directory.Directory.Exists("")is false, soIsDirectorywas wrong.Change
".". That is howNormalize()already writes the starting directory. TheParentXML doc is updated to match. AnullfromGetDirectoryName(a root) still maps to""inSemanticFilePath.DirectoryPath.PooledStringBuilder.CombinePathsdrops a leading".", as it already drops"". Without this,dir.Parent / dir.Namewould turnainto./a, andfile.RelativeDirectoryPath / file.FileNamewould turnx.txtinto./x.txt. Those still name the same location, but they are no longer equal by string. As a side effect,RelativeDirectoryPath(".") / xnow givesxinstead of./x.PathPolyfill.GetFullPath(netstandard2.0) resolves an empty path to the base path, which matchesPath.GetFullPath(path, basePath)on newer frameworks.Tests
""and now expect".". They areRelativeDirectoryPath_Parent_WithSingleComponent_*,RelativeFilePath_RelativeDirectoryPath_WithBareFileName_*, the("a", ".")row ofParent_ResolvesDotSegments,PathHierarchy_ParentTraversal_WorksCorrectly, andSemanticFilePath_DirectoryPath_OfABareFileName_IsTheStartingDirectory. They also assert thatAsAbsolute()returns the current directory and thatIsDirectoryis true.RelativeFilePath.DirectoryPathof a bare name is a real directory. Also added:RelativeDirectoryOperators_SingleSegmentParent_RoundTrips(Parent / Namegives backaandx.txt) and a base-directory resolution check.EmptyLeftOperand_StayRelativenow builds its empty operand directly, sinceParentno longer produces one.Semantics.Pathschanges reverted, 6 tests fail. With them, the fullSemantics.Testsuite passes 1965/1979, with 14 skipped as before.Semantics.Pathsbuilds clean for every target, netstandard2.0 included. The test project is net10.0 only, so the netstandard2.0 polyfill branch is compiled but not exercised by a test.#503, the
Parent / Nameround trip for paths ending in..or., is related but separate and is left for its own change.Generated by Claude Code