Skip to content

[Sonic] Support multiple C# documents in Rename - #84134

Merged
davidwengier merged 14 commits into
dotnet:features/sonicfrom
davidwengier:razor-sonic-tooling
Jun 16, 2026
Merged

[Sonic] Support multiple C# documents in Rename#84134
davidwengier merged 14 commits into
dotnet:features/sonicfrom
davidwengier:razor-sonic-tooling

Conversation

@davidwengier

@davidwengier davidwengier commented Jun 15, 2026

Copy link
Copy Markdown
Member

Yet another

Microsoft Reviewers: Open in CodeFlow

davidwengier and others added 3 commits June 15, 2026 12:56
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>
Copilot AI review requested due to automatic review settings June 15, 2026 03:32
@davidwengier
davidwengier requested a review from a team as a code owner June 15, 2026 03:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings June 15, 2026 03:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@davidwengier
davidwengier marked this pull request as draft June 15, 2026 05:46
davidwengier and others added 2 commits June 15, 2026 16:42
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidwengier
davidwengier marked this pull request as ready for review June 15, 2026 10:42
Copilot AI review requested due to automatic review settings June 15, 2026 10:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

@ToddGrun ToddGrun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copilot AI review requested due to automatic review settings June 16, 2026 00:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@davidwengier
davidwengier merged commit bb1a6a6 into dotnet:features/sonic Jun 16, 2026
25 checks passed
@davidwengier
davidwengier deleted the razor-sonic-tooling branch June 16, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants