skip to Main Content

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


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

    Login or Signup to reply.
  2. 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 called MyEnum 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).

    enter image description here

    It’ll take you to the ILSpy window. Next right click on the interface in question and select Analyze

    enter image description here

    Analyze window results:

    enter image description here

    Used by window results. There’s MyEnum and everything else in the codebase that uses IEnumerable<T> interface
    enter image description here

    Consider dotPeek as an alternative solution as well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search