[Sonic] Call hierarchy support for multiple C# documents - #84149
Merged
davidwengier merged 2 commits intoJun 16, 2026
Conversation
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 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
PrepareCallHierarchyHandlerto accept an explicitpreferredDocumentIdfor item creation. - Re-enable previously skipped cohost call hierarchy tests and add legacy Razor-file-kind variants; plumb
RazorFileKindinto 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. |
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.
Pretty straight forward, just need to try both documents sometimes.
Microsoft Reviewers: Open in CodeFlow