-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expected behavior for Go To Definition for metadata references #24349
Comments
A few comments:
|
This is step 4 of the original workflow.
This is a somewhat orthogonal discussion (if/how to trigger Go To Definition separately from "Show Signatures"). Given the decompiler is currently only enabled at the explicit request of a developer, I believe it's reasonable to assume that the use of ILSpy in these cases is the desired behavior. |
I would love to see this. If this feature is implemented in sync with SourceLink, it can make debugging libraries so so much easier. Now, if you want to put a break-point inside a class, you have to find a path of step-into's that lead to the source file to be opened. Then, you can put you break-point and see how the code works. In fact, finding the "path of step-into's" can be very tricky, as the assemblies are optimized. I once spent nearly 4-5 hours and couldn't find the source of my problem. Then I switched to using ILSpy and I found it in less than an hour. And I was just disappointed that I couldn't put a break-point there and see the code live and in action. |
Is true! Is true: I support this: " I think it has a positive effect on the development of the community and can benefit more. NET Developers |
I think the people of dotnet foundation are "stand still and refuse to make progress ", they don't and wouldn't to think about why more and more .net programmer turn to Java! |
Is there any progress on this? Resharper has had this for a decade now. This is extremely useful functionality, for quickly verifying assumptions instead of scouring the internet for source files and documentation! |
isnt dnspy the right tool for the debugging? https://github.com/0xd4d/dnSpy |
@oliverjanik I agree. Visual Studio is getting to a point where I almost don't need resharper anymore. With IntelisenseExtender (which btw, should also be a standard option), this is basically the only thing I really need to be able to move to a leaner non-resharper world. When you've split your business code across several nuget packages with interdependencies, this sort of support is a pretty vital analysis feature, so I hope this will get some more attention soon. Wish I could help, but I'm way too scared of anything this close to metal. ;) |
That would be a question that hopefully @chuckries can answer. |
@TFTomSun It depends.
|
@chuckries The sources are hosted on an on premise gitlab instance. To reach that instance via https you need to authorize via 2FA. In the past Visual Studio had a built in browser window. Some people with on premise gitlab instances reported that it was possible to do the 2FA there to make source link work. I never tried it. The browser window was removed with VS2022. Anyways, you would always have the same problem, if you are working with private repositories, even on public git instances. There should be a solution to reach the private source files, for developers who are authorized. |
@chuckries Can you explain a bit more how I could authenticate for such scenarios via an external source node? |
@cjmld5 prs welcome. |
@zhyy2008z if due to the GFW,i mean,the inner ILSpy should also works as well,but it seems not work and fallback to the view of metadata |
Whats GFW? The reason for the lack of real source in your situation is likely due to targeting .NET 6, but using a later SDK. In that case your projects are probably referencing nuget packages that literally do not contain any code, or SourceLink information, so there is nothing that Roslyn can use to find the right code. At runtime you'll roll forward and use whatever SDK is installed based on various rules and logic in the SDK resolvers, but Roslyn does not have that logic or information. We made it a little smarter, and it has some logic to pull the real info from SDK targetting packs, and nuget packages that contain both reference and implementation assemblies, but it doesn't cover all scenarios. There is probably a little bit of input in the Output window, the "Navigate to External Sources" category, that could validate my guess here. |
Without GFW, you can use the source link, that's what I found! Please forgive me for not mentioning inner ILSpy, I haven't looked into it. |
@davidwengier With the users appearing to be from Asia, I my guess would be GFW stands for "The Great Firewall". Basically China blocking western servers? I also assume Jailbreaking is referring to bypassing the firewall in some way. |
i see then output window,and sometime it says 1: timeout of downloading from pdb server, and each case can not fallback to the inner ILSpy |
We updated to 8.1 here: https://github.com/dotnet/roslyn/pull/69772/files |
Reference assemblies don't have IL that can be decompiled into useful code. If the downloads timeout, we fall back to decompilatuon if we can, and only if that fails do we use metadata. Also if a download timeout, we stop making you wait, but continue the download in the background, so a future attempt to go to something from that same assembly could succeed. |
It's Roslyn that provides the list of assemblies that the decompiler should load; the decompiler engine doesn't pick files by itself. |
@dgrunwald prs welcome :-) |
This comment was marked as off-topic.
This comment was marked as off-topic.
To be very clear here: The decompiler is doing nothing wrong, and VS doesn't "end up uselessly decompiling references assemblies". Roslyn is smart enough to know if something is a reference assembly, and in those cases we don't bother calling the decompiler. ILSpy is a wonderful piece of software. The problem here, as I've written in many comments in this thread, is that we don't have a way of finding the implementation assemblies, and in some cases its entirely possible that the implementation assemblies do not exist on the users machine at all. From a Roslyn point of view as the code is currently written, if a user asks to Go To Definition for a method in .NET 6, then that is what we will try to do. Rolling forward to .NET 8 might happen at runtime on that machine, but its not the code being referenced by that project, so we won't show it. Relaxing that rule, and writing the logic for how to do that lookup, is what it would take to move this issue forward from the Roslyn side. There are other approaches outside of Roslyn that could help here (see dotnet/sdk#12360 for example) but none of it is straight forward. |
@zhyy2008z they likely have some heuristic to do the mapping. As david mentioned, that's something that could be looked into. And we'd probably be open to PRs that help out here, if they're suitably sized and reasonable to maintain. Thanks! |
@zhyy2008z There's always the option to use the logic we employ in ILSpy to find implementation assemblies. However, this means that the framework(s) in question have to be installed on the machine and it would be necessary to implement some "ask the user which assembly to use" escape hatch. In ILSpy this is done by first looking in the active assembly list for references and using them. Only if an assembly cannot be resolved from the current list, we go looking for it in the filesystem using a myriad of hacks and crutches which luckily work most of the time. @CyrusNajmabadi Do you think it's worth the hassle implementing this feature using the code from ILSpy in VS? Ideally I would prefer to wait for an official solution from the people who designed .NET. |
I'm fine with either. |
Can anyone help with #68883 (comment) 🙏? |
Never found a good way in the VS good integrated source code view, ReSharper installed and uninstalled a very N times roslyn issue tracking, but also 6 years, and do not add this feature, I also want to traitor to Rider, our company's License to expire, to the point of not renewing it! |
The Navigate to Decompiled Sources feature recently added is the first step towards a better F12 experience. This issue describes the more complete picture for how this experience should eventually look.
🔗 AB#624702
The text was updated successfully, but these errors were encountered: