Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find All References To Child Method

I want to find all calls to DateTime.ToString references in my assembly. In Visual Studio you can "Find All References" by right clicking on ToString; however, that returns all references to ToString for all classes and not just DateTime.

A regular search for DateTime.ToString won't work because of the following example:

DateTime myDate = new DateTime();
myDate.ToString();

Any suggestions?

like image 714
Rafi Avatar asked May 22 '14 17:05

Rafi


3 Answers

You should use ReSharper for that.

Steps:

  1. Download and install ReSharper (trial version will work for you)
  2. Open your project/solution in Visual Studio
  3. Find usage of ToString(), like myDate.ToString();
  4. Right click on ToString token
  5. Select Find Usages Advanced ... menu item
  6. Tick the appropriate boxes in window as on screenshot below and click Find
  7. PROFIT

enter image description here

like image 185
alex.b Avatar answered Nov 16 '22 09:11

alex.b


In VS2015 when you try to Find References for override method, you have them grouped by type in
Results like this: Find Symbol Results

enter image description here

like image 9
Jacob Avatar answered Nov 16 '22 09:11

Jacob


In Visual Studio 2019, right-click on the desired method name, and then click "View Call Hierarchy." A "Call Hierarchy" window appears at the bottom (by default) of Visual Studio. In the left pane, you'll see a tree representation of the projects that call the method. Within each project, the first item is "Calls To [MethodName]." Expand this first item for a list of methods. Clicking each method will change the right pane of the "Call Hierarchy" window to show the lines where the method is called. Double-click these lines to go to them and address them individually.

like image 3
user1325179 Avatar answered Nov 16 '22 11:11

user1325179