Reputation: 1239
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?
Upvotes: 5
Views: 1282
Reputation: 3734
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)
Upvotes: 1