Skip to content

Commit d294f4c

Browse files
committed
Add failing test for invocation.MethodInvocationTarget
This triggers a `ArgumentException`: "Could not find method overriding [...]. This is most likely a bug. Please report it."
1 parent dca4ed0 commit d294f4c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Castle.Core.Tests/DynamicProxy.Tests/OutRefParamsTestCase.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public virtual void MyMethodWithStruct(ref MyStruct s)
9292
}
9393
}
9494

95+
public class Factory
96+
{
97+
public virtual void Create<T>(out T result) => result = default(T);
98+
}
99+
100+
public class DerivedFactory : Factory
101+
{
102+
public override void Create<T>(out T result) => result = default(T);
103+
104+
}
105+
95106
[Test]
96107
public void CanAffectValueOfOutParameter()
97108
{
@@ -353,5 +364,13 @@ public void Exception_during_method_out_ref_arguments_set_interface_proxy_with_t
353364
Assert.AreEqual(23, param1);
354365
Assert.AreEqual("23", param2);
355366
}
367+
368+
[Test]
369+
public void Can_query_MethodInvocationTarget_for_overridden_class_method_having_a_generic_by_ref_parameter()
370+
{
371+
var interceptor = new WithCallbackInterceptor(invocation => _ = invocation.MethodInvocationTarget);
372+
var proxy = generator.CreateClassProxy<DerivedFactory>(interceptor);
373+
proxy.Create<object>(out _);
374+
}
356375
}
357-
}
376+
}

0 commit comments

Comments
 (0)