Repository navigation
Allow renaming a resource to a different case of its own name (#328) - #350
Merged
Merged
Conversation
…h#328) The conflict check matched the resource being renamed, so a case-only rename such as Srv01 -> srv01 failed with "already exists". Only a different resource with the new name is now a conflict, so renaming onto another resource's case variant is still refused, including in a config that already holds both variants. Renaming a resource to exactly its current name now succeeds without writing anything, instead of failing with "already exists".
VirSanctus
marked this pull request as ready for review
September 29, 2026 08:29
Owner
|
Amazing - thanks @VirSanctus ! |
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.
Part of #328 (case D)
Problem
A rename that only changes case fails:
RenameResourceUseCaserefuses the rename ifGetByNameAsync(newName)finds anything, and since names compare case-insensitively that lookup finds the resource being renamed. The Web UI rename dialog and the MCPrename_resourcetool go through the same use case, so they fail the same way.Fix
Only a different resource with the new name is a conflict now. The check looks through
GetAllOfTypeAsync<Resource>()for a match that is not the resource being renamed (compared by reference, since both lookups return the same instances). As you suggested, renaming onto another resource's case variant is still refused, whatever its kind.I compared by reference rather than skipping the conflict when
GetByNameAsync(newName)returns the resource itself, because in a config that already holdsDup61anddup61that lookup returns the first one.rename Dup61 DUP61would then succeed as a rename ontodup61's case variant.The
runsOnand connection rewrites already compare case-insensitively (#329), so they follow the new casing without changes.Renaming a resource to exactly its current name used to fail with "already exists"; it now returns early and succeeds without writing anything. In the Web UI that means pressing Save in the rename dialog without editing the name no longer shows an error.
Tests
Five CLI tests in
Tests/EndToEnd/ConnectionTests/RenameResourceTests.cs:rename_that_only_changes_case_updates_the_namerename_that_only_changes_case_updates_runs_on_and_connectionsrunsOnand connection endpoints get the new casingrename_onto_another_resources_case_variant_is_still_refusedrename_to_the_identical_name_leaves_the_file_unchangedrename_is_refused_when_the_config_already_holds_a_case_variantDup61/dup61configThe first, second and fourth fail on
stagingand pass with the fix. The third and fifth pass on both; they guard what must not change, and the fifth fails if the check is written as "skip the conflict when the match is the resource itself".I also checked the Web UI by hand in the Docker image built from this branch: renaming
Srv01tosrv01in the dialog goes to the page forsrv01, saving the dialog again without editing the name shows no error, and renaming it toOTHER01whileOther01exists shows the conflict in the dialog.Not included
Interaction with #348
This merges cleanly with #348, and the CLI tests pass on the merge (383/383).
Local results
dotnet format --verify-no-changes: cleanChecklist