diff options
author | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2017-09-01 02:13:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-01 02:13:35 +0300 |
commit | 13ea6e4d1b9641f18ab7280bced0674784367766 (patch) | |
tree | e502da70ae3c386fed842a385a5fcb7ebe760d2a /src/System.Private.Reflection.Core | |
parent | f61d77cf347f921991902274cfdb7eb310b0e641 (diff) |
Implement BindingFlags.DoNotWrapExceptions on Project N (#4437)
This was approved here.
https://github.com/dotnet/corefx/issues/22866
Ok, this one actually makes the feature work. Turned
out not to be too hard.
There are a couple of drive-by items being done here:
- Since the other Invoke overload on MethodInvoker
was only for its use, downgraded its visibility.
- Moved the catch in InvokeUtilites before the finally
that copies back arguments. We don't want to wrap
any exceptions out of the argument post-processing
steps.
Diffstat (limited to 'src/System.Private.Reflection.Core')
2 files changed, 4 insertions, 3 deletions
diff --git a/src/System.Private.Reflection.Core/src/Internal/Reflection/Core/Execution/MethodInvoker.cs b/src/System.Private.Reflection.Core/src/Internal/Reflection/Core/Execution/MethodInvoker.cs index b36793812..1234a12f9 100644 --- a/src/System.Private.Reflection.Core/src/Internal/Reflection/Core/Execution/MethodInvoker.cs +++ b/src/System.Private.Reflection.Core/src/Internal/Reflection/Core/Execution/MethodInvoker.cs @@ -22,11 +22,12 @@ namespace Internal.Reflection.Core.Execution public Object Invoke(Object thisObject, Object[] arguments, Binder binder, BindingFlags invokeAttr, CultureInfo cultureInfo) { BinderBundle binderBundle = binder.ToBinderBundle(invokeAttr, cultureInfo); - Object result = Invoke(thisObject, arguments, binderBundle); + bool wrapInTargetInvocationException = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0; + Object result = Invoke(thisObject, arguments, binderBundle, wrapInTargetInvocationException); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); return result; } - public abstract Object Invoke(Object thisObject, Object[] arguments, BinderBundle binderBundle); + protected abstract Object Invoke(Object thisObject, Object[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException); public abstract Delegate CreateDelegate(RuntimeTypeHandle delegateType, Object target, bool isStatic, bool isVirtual, bool isOpen); // This property is used to retrieve the target method pointer. It is used by the RuntimeMethodHandle.GetFunctionPointer API diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/OpenMethodInvoker.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/OpenMethodInvoker.cs index 4a5c891d3..f29b790f5 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/OpenMethodInvoker.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/MethodInfos/OpenMethodInvoker.cs @@ -15,7 +15,7 @@ namespace System.Reflection.Runtime.MethodInfos { internal sealed class OpenMethodInvoker : MethodInvoker { - public sealed override Object Invoke(Object thisObject, Object[] arguments, BinderBundle binderBundle) + protected sealed override Object Invoke(Object thisObject, Object[] arguments, BinderBundle binderBundle, bool wrapInTargetInvocationException) { throw new InvalidOperationException(SR.Arg_UnboundGenParam); } |