Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding Reference to Class & Methods

I am trying to find out all the classes and assemblies which are using/referencing a particular class. Is there any way to find out through programming in C#?

For example, if Class1 is called/referenced by Class2 in Assembly1, Class3 in Assembly2, I want to find Class2 & Class3 using C# programming.

Is there anyone who could help me? Is there any tool that could help in this? I want to write a small program to read class from one assembly and find the classes where that particular class is referenced/used.

My question in short: How to find unused class or method in my codebase by writing a C# program as a part of code cleanup activity?

like image 648
nRk Avatar asked Nov 14 '22 12:11

nRk


1 Answers

If you're looking for a tool to do this, you could use NDepend which can do what you're describing and also a lot more.

Or, if you're using ReSharper: Right-Click, "find usages"... (not useful for finding unused code indeed)

like image 200
Stefan Paul Noack Avatar answered Nov 16 '22 03:11

Stefan Paul Noack