ChrisNel52
ChrisNel52

Reputation: 15133

How to Search Multiple Projects to Find Where a Specific Class's Method is being Invoked

We currently have multiple .NET projects that we have developed using Visual Studio. Each project has a reference to a shared dll that contains some helper classes.

Let's say I have an instance class named 'Helper1' with a public method named 'Save()'. Does anyone know of a way for me to search a group of projects to determine which projects/line the Save() method belonging to the Helper1 class is being invoked?

Basically, I want a list of where the Helper1 class' Save() method is being used among multiple projects.

This is not as simple as doing a text search. There could be many other classes in these projects that also have a Save() method which is being invoked, but I don't care about them. I only want to know about the Save() method belonging to the Helper1 class.

This means, the tool performing the search needs to be smart enough to understand the current namespace it is searching in. When a Save() method is found, the search tool needs to determine if the Save() method belongs to the Helper1 class or to some other class.

Note: There is no dynamic dependency injection happening in these projects, so we know at compile time which classes are being used.

Upvotes: 3

Views: 189

Answers (2)

Cody Gray
Cody Gray

Reputation: 244702

Red Gate's .NET Reflector can do this, even in the free version.

The "Analyze" feature will tell you where specific types are used, exposed, and instantiated:

   .NET Reflector Analyzer

If you find yourself needing something a little bit more high powered, you might look into Tom Carter's Dependency Structure Matrix Plugin. This works with Reflector to give you a more powerful way of tracking inter-module dependencies. You can read an article about it here.

Upvotes: 2

Marc Gravell
Marc Gravell

Reputation: 1062550

  • Load all the dlls into "reflector" (the free version is fine)
  • navigate to the method you are interested in
  • bring up the analyser (ctrl+r I believe)
  • job done

Upvotes: 2

Related Questions