Add willRenameFiles support, and an abstraction for extenders to implement#81549
Merged
davidwengier merged 5 commits intodotnet:mainfrom Dec 5, 2025
Merged
Add willRenameFiles support, and an abstraction for extenders to implement#81549davidwengier merged 5 commits intodotnet:mainfrom
davidwengier merged 5 commits intodotnet:mainfrom
Conversation
davidwengier
commented
Dec 5, 2025
|
|
||
| foreach (var listener in renameListeners) | ||
| { | ||
| var edit = await listener.Value.HandleWillRenameAsync(request, requestContext, cancellationToken).ConfigureAwait(false); |
Member
Author
There was a problem hiding this comment.
Rather than have Roslyn bother to handle globs, and deal with the complexity of one willRenameFiles request possibly containing multiple files that multiple handlers would want to know about, it seemed easier to just have each handler check the actual files being renamed and see if they care. They'd want to do it anyway.
dibarbet
reviewed
Dec 5, 2025
| }; | ||
| serverCapabilities.ImplementationProvider = true; | ||
|
|
||
| if (clientCapabilities.Workspace?.FileOperations?.WillRename ?? false) |
Member
There was a problem hiding this comment.
This only applies to VS - should probably be added here for vscode as well?
https://github.com/dotnet/roslyn/blob/main/src/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs
Member
Author
davidwengier
commented
Dec 5, 2025
src/LanguageServer/Protocol/Handler/Rename/ILspWillRenameListener.cs
Outdated
Show resolved
Hide resolved
dibarbet
approved these changes
Dec 5, 2025
This was referenced Dec 10, 2025
davidwengier
added a commit
to dotnet/razor
that referenced
this pull request
Jan 7, 2026
#12561) Fixes #8541 Fixes #11493 Needs dotnet/roslyn#81549 before this will build, but Roslyn CI seems to be having issues, so putting this up while we wait. This implements `workspace/willRenameFiles` support in our LSP server, so that when a `.razor` file is renamed, we perform a full rename of the component, including updating component tags and getting Roslyn changes for renaming the class name. In VS we also include a poly-fill since `willRenameFiles` is not supported, and an extra "apply rename" method to fill in the difference between real `willRenameFiles` support, where edits are made _before_ file renames, and our polyfill which lets CPS handle the file rename, and applies the edits afterwards. VS:  VS Code: 
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 dotnet/razor#8541
Adding functionality to Razor so that when a .razor file is renamed, the relevant component tags and any C# references are updated, so need willRename support. Since its a workspace request, if we implement it then Roslyn won't be able to, so best to support it in Roslyn and delegate to Razor as required.