Skip to content

Comments

Fix SourceLink go-to-definition failure when .NET 10 is used on Linux#1441

Merged
Krzysztof-Cieslak merged 2 commits intoionide:mainfrom
serefarikan:sourcelink-fix-pr
Feb 23, 2026
Merged

Fix SourceLink go-to-definition failure when .NET 10 is used on Linux#1441
Krzysztof-Cieslak merged 2 commits intoionide:mainfrom
serefarikan:sourcelink-fix-pr

Conversation

@serefarikan
Copy link
Contributor

@serefarikan serefarikan commented Dec 21, 2025

Summary

Fix SourceLink go-to-definition failure on .NET 10 for FSharp.Core symbols (e.g., List.map).

Problem

Go-to-definition fails for FSharp.Core symbols on .NET 10 with error MissingSourceFile, while working correctly on .NET 9.

Root cause: FSharp.Core 10.x is built on Linux (was Windows for 9.x), so PDB paths use forward slashes. On Linux, Path.GetFileName correctly strips the directory, leaving just the basename (list.fs), which then fails to match the full PDB document path (/__w/1/s/.../list.fs).

Changes

  1. ParseAndCheckResults.fs (getFileName): Keep the full FCS path instead of calling Path.GetFileName on non-Windows. Just normalize backslashes to forward slashes.
  2. Sourcelink.fs (compareRepoPath): Use suffix matching - the PDB document should be a suffix of (or equal to) the FCS path, to handle workspace prefixes FCS may add.

Tests

  • .NET 10 devcontainer (mcr.microsoft.com/dotnet/sdk:10.0.100-noble-aot) - go-to-definition on List.map now works
  • .NET 9 devcontainer (mcr.microsoft.com/devcontainers/dotnet:1-9.0) - no regression

Details

This PR aims to solve the issue described here: ionide/ionide-vscode-fsharp#2115

This has been a very interesting experience because I used claude code to track down the problem, then understand the root cause and implement a fix. I left the comments claude added in the code, because they clarify the context, though for the maintainers of this repo they may be just redundant.

I also tried to track down the changes to how fsharp core libraries are built, which took place with the .NET 10 release, but it is hard to find a single document that explains it. Overall, it looks like the sourcelink document metadata in fsharp dlls have changed. I added some debug statements to trace the document paths FCS returns and I can see that .net 9 and .net 10 environments have different values for the same entry:

  • FSharp.Core 9.x → PDB contains paths such as D:\a\_work\1\s\src\FSharp.Core\list.fs
  • FSharp.Core 10.x → PDB contains paths such as /__w/1/s/src/fsharp/src/FSharp.Core/list.fs

When FSharp.Core is built on Linux (as in .NET 10), the PDB contains
Linux-style paths. FSAC's getFileName was calling Path.GetFileName on
non-Windows, which stripped the directory portion, causing the PDB
document lookup to fail.

Fix:
- getFileName: Keep full FCS path, just normalize backslashes
- compareRepoPath: Use suffix matching to handle workspace prefixes
@serefarikan serefarikan changed the title Fix SourceLink go-to-definition failure on .NET 10 Fix SourceLink go-to-definition failure when .NET 10 is used on Linux Dec 21, 2025
@TheAngryByrd
Copy link
Member

Thanks for investigating! This seems to have broken Windows sourcelink lookups. Would you mind investigating those?

@serefarikan
Copy link
Contributor Author

That's interesting. I should not have assumed it'd work with Windows. I'll investigate.

On Windows, the PDB document paths retained backslashes while the FCS
path (already normalized) used forward slashes. This caused the path
comparison in compareRepoPath to fail even for matching files.

The fix converts backslashes to forward slashes when normalizing the
PDB document path on Windows, ensuring consistent path comparison.
@serefarikan
Copy link
Contributor Author

@TheAngryByrd I had to make a one line change. I tested the results and I can confirm the .net 10 build I've created in my local devcontainer env is working with both ubuntu (devcontainer) and native windows 10 instances of vs code in my local dev setup.

@Krzysztof-Cieslak Krzysztof-Cieslak merged commit 1cab58f into ionide:main Feb 23, 2026
35 of 38 checks passed
@Krzysztof-Cieslak
Copy link
Member

Thanks a lot!

@serefarikan
Copy link
Contributor Author

Thank you! It's a great feeling to be able to contribute back even the tiniest amount.

github-actions bot pushed a commit that referenced this pull request Feb 23, 2026
Summarise changes merged since v0.83.0:
- Fix SourceLink go-to-def on .NET 10 Linux (#1441)
- Add backgroundServiceProgress config option (#1452)
- Fix { trigger char for interpolated strings (#1454)
- Fix non-ASCII URI encoding (#1455)
- Fix spurious get/set rename (#1453)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Feb 24, 2026
Include all PRs merged since v0.83.0:
- #1441: Fix SourceLink go-to-def failure on .NET 10 on Linux
- #1452: Add FSharp.notifications.backgroundServiceProgress config option
- #1449: Fix semantic token multiline range uint32 underflow
- #1453: Fix spurious get/set rename in TextDocumentRename
- #1454: Fix missing { interpolated string completion trigger
- #1455: Fix non-ASCII path encoding in file URIs
- #1456: Disable inline values by default to restore pipeline hints
- #1457: Fix missing parens in function-type segments in AddExplicitTypeAnnotation
- #1458: Fix signature help parameter types showing fully-qualified names
- #1463: Fix seealso href/langword XML doc rendering

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants