Member predicate ObjectCreation::getARuntimeTarget
Gets a potential run-time target of this call.
A potential target is a callable that is neither abstract nor defined in an interface.
Unlike getTarget()
, this predicate takes reflection/dynamic based calls,
virtual dispatch, and delegate calls into account. Example:
class A {
virtual void M() { }
}
class B : A {
override void M() { }
static void CallM(A a) {
a.M();
typeof(A).InvokeMember("M", BindingFlags.Public, null, a, new object[0]);
}
}
class C {
void M2(Action<int> a) {
a(0);
}
static void CallM2(C c) {
c.M2(i => { });
}
}
-
Line 9: The static target is
A.M()
, whereas the run-time targets are bothA.M()
andB.M()
. -
Line 10: The static target is
Type.InvokeMember()
, whereas the run-time targets are bothA.M()
andB.M()
. -
Line 16: There is no static target (delegate call) but the delegate
i => { }
(line 20) is a run-time target.