You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I misunderstand the meaning of IInvocation.InvocationTarget and IInvocation.MethodInvocationTarget, I would expect the latter to point to a method of the former's type, if the former (IInvocation.InvocationTarget) is non-null.
Actual outcome
MethodInvocationTarget will throw an ArgumentNullException due to the invocation's targetType not being set.
If I understand things correctly, then generally speaking the "target" is whatever one can .Proceed() to:
For composition-based proxies, a target object can be supplied explicitly.
For inheritance-based proxies, the target can be either missing (i. e. null) or the intercepted method's implementation inherited from the proxied type.
If the above assumptions are correct, then for an IInvocation representing an intercepted default interface method...:
invocation.TargetType should return the interface type where the default implementation resides.
invocation.InvocationTarget should return the same as invocation.Proxy.
invocation.MethodInvocationTarget should return the MethodInfo of the method with the default implementation... so possibly the same as invocation.Method?
@jonorossi, sorry to bother you again, but are my assumptions and conclusions correct, or am I missing some finer distinctions?
Repro code
Expected outcome
Unless I misunderstand the meaning of
IInvocation.InvocationTarget
andIInvocation.MethodInvocationTarget
, I would expect the latter to point to a method of the former's type, if the former (IInvocation.InvocationTarget
) is non-null.Actual outcome
MethodInvocationTarget
will throw anArgumentNullException
due to the invocation'stargetType
not being set.Affected version(s)
Castle.Core starting at tag
v5.2.0
/cc @dtchepak @zvirja @alexandrnikitin – this will likely matter for NSubstitute (in https://github.com/nsubstitute/NSubstitute/blob/4d258a28aba054ea18785d36b4bdd83da023aefb/src/NSubstitute/Proxies/CastleDynamicProxy/CastleInvocationMapper.cs#L11-L16) once we've published version 5.2.0 and you upgrade to that version.
The text was updated successfully, but these errors were encountered: