dotnet / dotnet/roslyn

[LanguageServer] TextDocumentIdentifier for external sources not recognized when client expands symbolic links

Open
#78,611 1 comment 5 reactions 0 assignees View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**: 13f74f71607b2cfbd8197e21c906e098a4cb0ee8

**Steps to Reproduce**:
1. Send a `textDocument/definition` request for a symbol outside of the solution. The response will contain the decompiled source. However, the URI may contain a symbolic link (`/var` -> `/private/var` on macOS).

Neovim log:
[DEBUG][2025-05-16 16:37:22] .../vim/lsp/rpc.lua:330 "rpc.receive" { id = 44, jsonrpc = "2.0", result = { { range = { ["end"] = { character = 57, line = 11 }, start = { character = 37, line = 11 } }, uri = "file:///var/folders/_c/27x2ds_55459nbcfj6px_gyr0000gn/T/MetadataAsSource/ef68949c40424a8b849218311ab7e85e/DecompilationMetadataAsSourceFileProvider/76ac2437f9b24ff8be3ba8946d44496b/ServiceProviderConfig.cs" } } }

2. When navigating to the decompiled source, the client may send subsequent requests using the expanded path (`/private/var/...` instead of `/var/...`).

[DEBUG][2025-05-16 16:37:23] .../vim/lsp/rpc.lua:216 "rpc.send" { id = 46, jsonrpc = "2.0", method = "textDocument/semanticTokens/full", params = { textDocument = { uri = "file:///private/var/folders/_c/27x2ds_55459nbcfj6px_gyr0000gn/T/MetadataAsSource/ef68949c40424a8b849218311ab7e85e/DecompilationMetadataAsSourceFileProvider/76ac2437f9b24ff8be3ba8946d44496b/ServiceProviderConfig.cs" } } }

**Expected Behavior**:
When the language server returns a URI that contains symbolic links, future references by the client using the expanded path are treated the same.

**Actual Behavior**:
[DecompilationMetadataAsSourceFileProvider.TryAddDocumentToWorkspace](https://github.com/dotnet/roslyn/blob/0d6bd9de68dc7e15165dffc8934fe2f473b2c171/src/Features/Core/Portable/MetadataAsSource/DecompilationMetadataAsSourceFileProvider.cs#L283) requires the URI from the request to use the symbolic link `/var/...`. There may be other places.

Contributor guide

Open the contributing guide

Research direction

Start at DecompilationMetadataAsSourceFileProvider.TryAddDocumentToWorkspace in src/Features/Core/Portable/MetadataAsSource/DecompilationMetadataAsSourceFileProvider.cs, then compare the returned definition URI with the later textDocument/semanticTokens request shown in the report. Trace related URI handling for external decompiled documents. Done means requests using the client’s expanded symbolic-link path are treated as the same document.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.