[Sonic] Support multiple C# documents in Rename - #84134
Merged
davidwengier merged 14 commits intoJun 16, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Razor cohost rename handling to correctly operate when a Razor document produces multiple generated C# documents (declaration vs implementation), and adjusts mapping logic to avoid duplicate/overlapping edits when those documents map back onto the same Razor spans. It also enables/extends cohosting rename/prepare-rename test coverage that was previously skipped.
Changes:
- Update remote rename and prepare-rename paths to request the appropriate generated C# document (declaration vs implementation) and map ranges via the matching C# document.
- Deduplicate mapped workspace edits to prevent failures when identical Razor edits are produced multiple times (e.g., from decl+impl rename flows).
- Unskip and extend cohost rename/prepare-rename unit tests, adding new scenarios that exercise rename from additional C# locations and directive-driven renames.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/Endpoints/CohostRenameEndpointTest.cs | Enables/adds rename tests and adds a parameter to target a specific Razor document file path in multi-file scenarios. |
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/Endpoints/CohostPrepareRenameEndpointTest.cs | Enables the C# prepare-rename test case previously skipped. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Rename/RemoteRenameService.cs | Uses decl/impl-aware generated document selection and correct C# document mapping for rename/prepare-rename; improves component file rename for SONIC decl doc. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/DocumentMapping/RazorEditService_WorkspaceEdit.cs | Deduplicates mapped edits (and dedupes within TextDocumentEdit) to avoid overlapping-change failures when applying workspace edits. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
davidwengier
marked this pull request as draft
June 15, 2026 05:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ToddGrun
reviewed
Jun 15, 2026
ToddGrun
reviewed
Jun 15, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Yet another
Microsoft Reviewers: Open in CodeFlow