Skip to content

Paths: dir.Parent / dir.Name names a different directory when the path ends in .. or ., breaking the documented round trip #503

Open

Description

@matt-edmondson

What's wrong

Since #498 (cf1dd3d), the Name docs on AbsoluteDirectoryPath (Implementations/AbsoluteDirectoryPath.cs:74) and DirectoryPath (Primitives/DirectoryPath.cs:43) promise: "so Parent / Name is this directory again". The two halves read different forms of the path:

  • Parent resolves . and .. first: GetFullPath for absolute paths, Normalize for relative ones.
  • Name is Path.GetFileName(WeakString), the last segment exactly as written.

Observed (net10.0 build)

Path Names Parent / Name Which resolves to
absolute /home/user/.. /home /.. /
relative a/.. . ../.. two levels up
relative . . ../. ..
DirectoryPath("/") / '' Parent and Name are both empty

Code that rebuilds a path from its parent and name, for example to move a directory to a new parent while keeping its name, ends up in the wrong place for these inputs. Nothing raises an error.

Suggested fix

Either:

  1. derive Name from the same resolved form Parent uses: Path.GetFileName(Path.GetFullPath(WeakString)) for absolute paths, and the last segment of Normalize() for relative ones; or
  2. if the as-written name is intended (an existing remark says the name of /home/user/.. is ..), narrow the doc promise to paths with no ./.. segments and that are not roots.

Acceptance criteria

  • Either Parent / Name equals the directory, by resolved path, for the four inputs above, or the docs state the exception and tests pin the chosen behaviour.

Activity

  1. added
    bug
    on Oct 30, 2026
  2. matt-edmondson commented on Oct 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions