dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.92k stars 4.02k forks source link

Source Link support in Go To Definition #55834

Open davidwengier opened 3 years ago

davidwengier commented 3 years ago

Allow Go To Definition to pull sources from Source Link enabled assemblies.

See also https://github.com/dotnet/roslyn/issues/24349

Background:

Process:

Also:

terrajobst commented 2 years ago

@jmarolf I think you want this to be either Epic or Theme, probably Epic, right?

davidwengier commented 2 years ago

I feel strangely violated

jmarolf commented 2 years ago

Sorry @davidwengier I am labeling things to see what happens on themeof.net. They don't mean anything yet. Just experiementing

terrajobst commented 2 years ago

They don't mean anything yet.

Now I feel strangely violated

Meligy commented 2 years ago

Is this supposed to work even partially with "remoteHub.richNavigation.enabled": true? Spotted it in https://github.com/dotnet/roslyn/issues/24349#issuecomment-1205757676 but probably does not work for non remote repos.

davidwengier commented 2 years ago

@Meligy I'm not sure what that setting means, nor where you would set it. In general Go To Def works regardless of what repo code may come from, but the Source Link aspect would not work if there wasn't Source Link information in the PDBs of the referenced DLLs. If you're having issues with things not working, it's probably best to just log an issue and we can investigate.

Meligy commented 2 years ago

Hi @davidwengier. Thanks for the reply and sorry for not providing enough context. I was checking why Omnisharp decompilation support was not showing implementation for BCL methods (for a simply example, Array.Empty<int>()). And my googling led to https://github.com/dotnet/roslyn/issues/24349#issuecomment-1205757676. The setting I mentioned my previous reply is what's shown in the VS Code Settings picture in the comment. I wasn't sure if it's related or not, hence the question.

I understand that in Visual Studio (at least for Windows, maybe for Mac but did not check) there are settings to add symbol servers, download symbols from them, and use these for debugging and maybe decompilation. I was hoping there was something similar when consuming Roslyn via VS Code / Omnisharp.

davidwengier commented 2 years ago

Unfortunately the components that enable Roslyn to download PDBs and Source Link files are part of Visual Studio, and don't ship with OmniSharp/the C# extension.

JoeRobich commented 2 years ago

@Meligy The documentation for configuring Symbol and Source Link options for the .NET Core Debugger in the C# extension can be found at https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#symbol-options

Meligy commented 2 years ago

@JoeRobich thanks a lot. I was actually wondering more about decompilation without debugging (think: right click a symbol and choose "Go to Definition/implementation"). But this is also very useful. I wonder if once downloaded, this become available to use even without debugging.

JoeRobich commented 2 years ago

@Meligy If you set omnisharp.enableDecompilationSupport to true and accept the terms, then with a restart you are able to go to decompilation with the C# extension in VS Code. If you had previously rejected the terms, then you can run the "CSharp: Show decompilation terms agreement" command.