Skip to content

[Sonic] Call hierarchy support for multiple C# documents - #84149

Merged
davidwengier merged 2 commits into
dotnet:features/sonicfrom
davidwengier:razor-sonic-call-hierarchy
Jun 16, 2026
Merged

[Sonic] Call hierarchy support for multiple C# documents#84149
davidwengier merged 2 commits into
dotnet:features/sonicfrom
davidwengier:razor-sonic-call-hierarchy

Conversation

@davidwengier

@davidwengier davidwengier commented Jun 16, 2026

Copy link
Copy Markdown
Member

Pretty straight forward, just need to try both documents sometimes.

Microsoft Reviewers: Open in CodeFlow

davidwengier and others added 2 commits June 16, 2026 17:19
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 16, 2026 07:24
@davidwengier
davidwengier requested review from a team as code owners June 16, 2026 07:24

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 call hierarchy to better handle Razor’s paired C# source-generated documents (implementation vs. declaration) by (1) preferring the right generated document for “prepare” and (2) resolving the correct generated document when requesting incoming/outgoing calls for a specific CallHierarchyItem. It also enables and expands unit test coverage to validate the updated behavior (including legacy Razor file kind).

Changes:

  • Update Razor remote call hierarchy to retry “prepare” preferring the declaration generated document when the implementation document can’t produce an item, and to resolve the correct generated document per call-hierarchy item for incoming/outgoing calls.
  • Extend Roslyn LSP PrepareCallHierarchyHandler to accept an explicit preferredDocumentId for item creation.
  • Re-enable previously skipped cohost call hierarchy tests and add legacy Razor-file-kind variants; plumb RazorFileKind into test document creation.

Reviewed changes

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

File Description
src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/Endpoints/CohostCallHierarchyEndpointTest.cs Enables call hierarchy endpoint tests and adds legacy RazorFileKind coverage to validate multi-generated-document scenarios.
src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/CallHierarchy/RemoteCallHierarchyService.cs Improves generated-document selection for prepare/incoming/outgoing call hierarchy requests, including declaration-doc retry and per-item generated doc resolution.
src/LanguageServer/Protocol/Handler/CallHierarchy/PrepareCallHierarchyHandler.cs Adds an explicit preferredDocumentId parameter to support selecting the right declaration document when creating call hierarchy items.

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

@davidwengier
davidwengier merged commit 8160059 into dotnet:features/sonic Jun 16, 2026
25 checks passed
@davidwengier
davidwengier deleted the razor-sonic-call-hierarchy branch June 16, 2026 21:49
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