Reputation: 4296
There are two calls to the function B:Bla below, but looking at the call hierarchy (Cntl-K Cntl-T) and then 'Calls to' for each of A:Bla and B:Bla yields that one call is going to A and one call is going to B.
I'm working on a very large code base and sometimes I want the all calls to a function and I don't want to click 'Calls to' for each function in the inheritance chain. So for the below example, I would like 'Calls to' to return both calls, regardless of whether I called it on A:Bla or B:Bla.
using System;
class A
{
public virtual int Bla() {
return 65;
}
}
class B : A
{
public override int Bla()
{
return 66;
}
int Helper()
{
return this.Bla();
}
static void Main()
{
A obj = new B();
Console.WriteLine(obj.Bla());
Console.Read();
}
}
Upvotes: 17
Views: 62159
Reputation: 52366
From the Visual Studio menu, select View - Call Hierarchy (Ctrl + Alt + K).
To find out from where the function is being called, look at the Call Sites section.
Upvotes: 0
Reputation: 423
Here are the basic shortcuts for function references :
Using Windows version 1.31.1
Upvotes: 3
Reputation: 866
In case someone finds their way here looking for a way to do it with VS Code:
shift
+F12
, or Find All References
Upvotes: 2
Reputation: 7769
In Visual Studio 2015, try View | Call Hierarchy, or Ctrl + Alt + K
on standard keyboard mapping. This brings up a tree with "call to " and "Calls from " subtrees.
Unfortunately, unlike Eclipse CDT, this call graph does not appear to be indexed.
Upvotes: 5
Reputation: 1153
You can use the 'Find All References' function, highlight the method in question and press Ctrl + F12, or right click and pick Find All References.
This will then show the results in the Find Symbol Results window.
Please see this link for more details information. http://www.blackwasp.co.uk/VSFindAllReferences.aspx
Upvotes: 13