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
RemoveExtension() on a dotfile (.bashrc, .gitignore) returns the parent directory, or /, as a file path #325
AbsoluteFilePath.RemoveExtension() (Semantics.Paths/Implementations/AbsoluteFilePath.cs around lines 76–79) and the same method on RelativeFilePath do this:
.NET treats a leading-dot file name as consisting entirely of an extension. So Path.ChangeExtension("/home/user/.bashrc", null) returns "/home/user/". SemanticPath.MakeCanonical then strips the trailing separator, and the result is the parent directory, typed as a file path.
"/home/user/.bak", which renames the file instead of adding an extension
Why it matters
Code such as File.Move(path, path.RemoveExtension()) or a cleanup that deletes path.RemoveExtension() silently targets a directory. The strong typing is supposed to rule out exactly this kind of mistake.
Suggested fix
Operate on the file name only. If Path.GetFileName has no . after index 0, RemoveExtension() returns the path unchanged and ChangeExtension appends the new extension. Apply the same dotfile rule to the FileExtension/FullFileExtension getters that #287 is deciding, so all extension members agree.
Acceptance: tests cover /home/user/.bashrc, /.profile, .gitignore and src/.editorconfig for both RemoveExtension and ChangeExtension, on absolute and relative file paths. RemoveExtension returns a path whose file name is unchanged, and ChangeExtension(".bak") yields .bashrc.bak.
Priority: High. RemoveExtension() on a dotfile silently returns the parent directory, or /, typed as a file path. ChangeExtension renames the file instead of adding an extension. Any move or delete built on the result targets the wrong filesystem object. That is exactly the kind of mistake the strongly typed paths are meant to prevent.
Area / suggested assignment:Semantics.Paths (AbsoluteFilePath / RelativeFilePathRemoveExtension and ChangeExtension)
Suggested next step: work on Path.GetFileName only, and treat a name whose only . is at index 0 as having no extension. Cover the four repro paths on both absolute and relative types.
Activity
matt-edmondson commentedon Sep 29, 2026
Triage
RemoveExtension()on a dotfile silently returns the parent directory, or/, typed as a file path.ChangeExtensionrenames the file instead of adding an extension. Any move or delete built on the result targets the wrong filesystem object. That is exactly the kind of mistake the strongly typed paths are meant to prevent.Semantics.Paths(AbsoluteFilePath/RelativeFilePathRemoveExtensionandChangeExtension)FileExtension/FullFileExtension). Settle one dotfile rule and apply it to every extension member, ideally in one PR.Suggested next step: work on
Path.GetFileNameonly, and treat a name whose only.is at index 0 as having no extension. Cover the four repro paths on both absolute and relative types.Generated by Claude Code
Treat a dotfile as having no extension in RemoveExtension and ChangeE…