Skip to content

[Sonic] Support multiple C# documents in hover - #84031

Merged
davidwengier merged 7 commits into
dotnet:features/sonicfrom
davidwengier:SonicHover
Jun 5, 2026
Merged

[Sonic] Support multiple C# documents in hover#84031
davidwengier merged 7 commits into
dotnet:features/sonicfrom
davidwengier:SonicHover

Conversation

@davidwengier

@davidwengier davidwengier commented Jun 5, 2026

Copy link
Copy Markdown
Member

I decided to continue the work to move code from Workspaces up to Remote in this branch, rather than just generate conflicts in main, so this has a little more in it, but the diffs are just namespace changes. Also has one commit from the document highlight change in here, so you might have seen it before.

The changes to RemoteHoverService really highlight how useful the InDeclDocument bool can be.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings June 5, 2026 05:42
@davidwengier
davidwengier requested a review from a team as a code owner June 5, 2026 05: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

This PR updates Razor cohosting hover plumbing to correctly handle Razor positions that map into either the implementation or declaration generated C# document, and aligns the related hover helpers/types under the Remote Razor layer with updated unit coverage.

Changes:

  • Thread an InDeclDocument flag through Razor→C# position mapping so callers can choose the correct generated C# document.
  • Update RemoteHoverService to request C# hover from the appropriate generated document and map hover ranges back using the matching C# document.
  • Move/rename hover helpers into Microsoft.CodeAnalysis.Remote.Razor.Hover and expand cohosting hover tests to cover impl/decl/legacy scenarios.

Reviewed changes

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

Show a summary per file
File Description
src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Remote.Razor.UnitTests/Hover/HoverFactoryTest.cs Updates test namespace/imports to match the moved Remote hover types.
src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/ProjectAvailabilityTests.cs Updates ComponentAvailabilityService namespace usage after the move.
src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/Endpoints/CohostHoverEndpointTest.cs Renames/extends hover tests to validate impl/decl/legacy C# hover behavior.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs Uses the new Razor→C# mapping helper to capture InDeclDocument when preferring C# over HTML.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/RemoteHoverService.cs Uses InDeclDocument to pick the correct generated C# document and to map ranges back correctly.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/HoverFactory.cs Moves hover factory into the Remote hover namespace (no functional changes observed here).
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/HoverDisplayOptions.cs Moves hover display options into the Remote hover namespace.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/ComponentAvailabilityService.cs Moves ComponentAvailabilityService into the Remote hover namespace.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs Updates import for ComponentAvailabilityService after its namespace move.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs Adds a convenience mapping helper that checks both impl/decl C# documents and returns inDeclDocument.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs Propagates InDeclDocument when synthesizing provisional completion position info.

@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:

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