Repository navigation
Treat a dotfile as having no extension in RemoveExtension and ChangeExtension [patch] - #426
Merged
Merged
Conversation
…xtension [patch] Path.ChangeExtension takes a leading-dot name as all extension, so RemoveExtension on /home/user/.bashrc returned /home/user typed as a file, and ChangeExtension renamed the file instead of appending. Both now strip only FileExtension, which already follows the dotfile rule, and FileNameWithoutExtension uses the same rule. Fixes #325 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QbGcYckSzgr6jPyoNYhWvA
|
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 #325
What changed
AbsoluteFilePath/RelativeFilePathusedPath.ChangeExtension, which treats a leading-dot name as all extension. That caused two bugs:RemoveExtension()on/home/user/.bashrcreturned/home/user(on/.profile, it returned/), typed as a file pathChangeExtension(".bak")returned/home/user/.bakinstead of.bashrc.bakSemanticFilePathgains twoprivate protectedhelpers built on the existingFileExtensionproperty, which already applies the dotfile rule from #287:WeakStringWithoutExtensionstrips onlyFileExtension. It still drops a trailing dot after the name (file.→file), asPath.ChangeExtensiondid.WeakStringWithExtension(ext)replaces the extension, or appends one when there is none.RemoveExtension,ChangeExtensionandFileNameWithoutExtensionon both file path types now use these helpers, so every extension member follows one rule. For example,.bashrc'sFileNameWithoutExtensionis now.bashrcinstead of an empty string.Tests
Semantics.Test/Paths/DotfileExtensionTests.cs:/home/user/.bashrc,/.profile,.gitignore,src/.editorconfig:RemoveExtensionleaves each path unchanged, andChangeExtension(".bak")appends to it, on both absolute and relative pathsFileNameWithoutExtensionreturns the whole name for a dotfilesrc/.config.jsonloses or replaces only.json, and a dot in a directory name (app.v2/README) is not an extensionWith the
Semantics.Pathschange stashed, 5 of the 7 tests fail; the two that pass check behaviour that was already correct. With the change applied, all 7 pass. The fullSemantics.Testsuite passes on net10.0 (1648 passed, 0 failed).Semantics.Pathsbuilds for every target framework.Open PRs #421–#423 touch other
Semantics.Pathsmembers, not these.🤖 Generated with Claude Code
https://claude.ai/code/session_01QbGcYckSzgr6jPyoNYhWvA
Generated by Claude Code