Skip to content

Conversation

@serefarikan
Copy link

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

1 participant