Skip to content

Drop the "." parent when DirectoryPath's / operators combine [patch] - #540

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/539-directorypath-combine
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/539-directorypath-combine

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #539

What was wrong

#504 made the parent of a one-segment relative path, and the directory of a bare file name, "." rather than "". It taught PooledStringBuilder.CombinePaths to drop a leading ".", but the primitive DirectoryPath's four / operators still called Path.Combine, and Path.Combine(".", "a") is "./a". As a result:

  • DirectoryPath("a").Parent / Name was "./a", not equal to DirectoryPath("a")
  • FilePath("x.txt").DirectoryPath / FileName was "./x.txt", not equal to the original

What changed

  • All four DirectoryPath / operators now go through PooledStringBuilder.CombinePaths, the same as RelativeDirectoryPath and AbsoluteDirectoryPath.
  • I added four tests to DirectoryNameRebuildTests: a single-segment Parent / Name round trip, a bare-file DirectoryPath / FileName round trip, and "." / RelativeFilePath and "." / RelativeDirectoryPath.

Testing

  • With the operator change reverted, all four new tests fail. With it, they pass.
  • Full Semantics.Test on net10.0 (Linux): 1999 passed, 14 skipped (Windows-only), 0 failed.

Generated by Claude Code

Since #504 the parent of a one-segment relative path, and the directory of a
bare file name, is ".". DirectoryPath's four / operators still called
Path.Combine, which keeps it, so DirectoryPath("a").Parent / Name was "./a"
and FilePath("x.txt").DirectoryPath / FileName was "./x.txt", neither equal to
the original. Route them through PooledStringBuilder.CombinePaths, as the
Relative* and Absolute* directory types already do.

Fixes #539

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW4iaJ7gETqBaPbNzq1
@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants