For the past 5 years, I’ve been using Java in Eclipse, where it’s possible to explore the code in my project’s dependencies, including viewing call hierarchies, finding all interface implementations, finding all references to a particular class, going directly to a particular type, etc. I learned a lot from being able to go spelunking in this way, and was able to diagnose many bugs without even running the code.
Now I’m returning to the .Net stack and Visual Studio (2022), and I want to do the same. However, the only things that show up in Call Hierarchy etc. are from my own code, not from dependencies. For example, I want to find all implementations of Microsoft.Extensions.Hosting.IHost
, and the window doesn’t even open. I tell it to "Find All References", and apparently there aren’t any. Even the Go To Type function only sometimes shows types from my dependencies.
Is there a way to go code-exploring in this way? Or is it just not possible in .Net due to some technical constraint?
2
Answers
By default, visual studio just show metadata of compiled dotnet sources
if you want to see the source code just download And install This Extension for Visual Studio
Don’t think there’s a native Visual Studio way of doing this.
However you can try ILSpy extension. Just install it via Extensions -> Manage Extensions -> Search for "ILSpy" -> click on
Download
. After restarting your VS it will be installed.Usage example:
Let’s say i want to see all usages of
IEnumerable<T>
. I’ve written an implementation for this interface calledMyEnum
as well just as an example.Right click on the interface and click
Open code in ILSpy
(you might need to build your project before this, haven’t really used this extension so i’m not that sure).It’ll take you to the ILSpy window. Next right click on the interface in question and select
Analyze
Analyze window results:
Used by window results. There’s
MyEnum
and everything else in the codebase that usesIEnumerable<T>
interfaceConsider dotPeek as an alternative solution as well.