dotnet / dotnet/roslyn

[Visual Studio] F12 Go to Definition on .NET 9 library types occasionally goes to the wrong files

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

Description

**Version Used**:
VS 17.14, .NET 9.0.3

**Steps to Reproduce**:
1. Create a trivial project targeting .NET 9
2. Add the following code to a class method:
```csharp
Process p = new Process();
p.OutputDataReceived
```
3. F12 `OutputDataReceived`
4. F12 again on the delegate type of `OutputDataReceived`, `DataReceivedEventHandler`

**Expected Behavior**:
F12 on `DataReceivedEventHandler` should go to `DataReceivedEventArgs.cs` [where it is defined in the runtime](https://github.com/dotnet/runtime/blob/f0230dbda533cbd6531e44d24bc0c6e298be56e8/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/DataReceivedEventArgs.cs#L6)

**Actual Behavior**:
F12 on `DataReceivedEventHandler` navigates to `Interop.GetModuleInformation.cs`

Additional notes:
- I have anecdotally hit this with other types.
- Closing the document and F12ing again continuously yields the same incorrect document.
- Verified on 2 separate machines / VS versions / .NET 9 versions
- Interestingly, public docs for `DataReceivedEventHandler` also list the wrong source document, though it is different from the one yielded by Go to Definition (`Interop.ForkAndExecProcess.cs`): https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.datareceivedeventhandler?view=net-9.0
- Even more curious, the .NET 10 version of the page (`?view=net10.0`) has the correct file.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Visual Studio 17.14 with a .NET 9 project using the listed Process and DataReceivedEventHandler steps. Compare F12's destination with the runtime's DataReceivedEventArgs.cs and the documentation links; done means F12 consistently opens the correct source file.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
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.