Skip to content

Commit d3eb112

Browse files
committed
Edge case: disallow invocation.CaptureProceedInfo
... when byref-likes are present, as they will be gone from the evalua- tion stack after the intercepted method has returned for the first time. (DynamicProxy could in theory be made to tolerate nullified `ByRefLike- Reference` substitutes, but this doesn't seem worth the effort: after all, `IInvocationProceedInfo` is intended mostly for async interception scenarios, and even C# disallows `ref struct`s in `async` methods.)
1 parent adcec9b commit d3eb112

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Castle.Core/DynamicProxy/AbstractInvocation.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ public void Proceed()
134134

135135
public IInvocationProceedInfo CaptureProceedInfo()
136136
{
137+
#if FEATURE_BYREFLIKE
138+
if (Array.Exists(Arguments, argument => argument is ByRefLikeReference) || ReturnValue is ByRefLikeReference)
139+
{
140+
throw new InvalidOperationException(
141+
"DynamicProxy does not currently support this operation " +
142+
"for methods with byref-like parameters or return types. ");
143+
}
144+
#endif
145+
137146
return new ProceedInfo(this);
138147
}
139148

0 commit comments

Comments
 (0)