diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs index 28d03e3ae491de..637e99a2fe5f91 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs @@ -228,27 +228,15 @@ private IntPtr GetActualTargetFunctionPointer(object thisObject) return OpenMethodResolver.ResolveMethod(_extraFunctionPointerOrData, thisObject); } - internal bool IsDynamicDelegate() => GetThunk(MulticastThunk) == IntPtr.Zero; - [DebuggerGuidedStepThroughAttribute] protected virtual object? DynamicInvokeImpl(object?[]? args) { - if (IsDynamicDelegate()) - { - // DynamicDelegate case - object? result = ((Func)_helperObject)(args); - DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); - return result; - } - else - { - DynamicInvokeInfo dynamicInvokeInfo = ReflectionAugments.GetDelegateDynamicInvokeInfo(GetType()); + DynamicInvokeInfo dynamicInvokeInfo = ReflectionAugments.GetDelegateDynamicInvokeInfo(GetType()); - object? result = dynamicInvokeInfo.Invoke(_target, _methodPtr, - args, binderBundle: null, wrapInTargetInvocationException: true); - DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); - return result; - } + object? result = dynamicInvokeInfo.Invoke(_target, _methodPtr, + args, binderBundle: null, wrapInTargetInvocationException: true); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } protected virtual MethodInfo GetMethodImpl() @@ -492,9 +480,6 @@ protected Delegate CombineImpl(Delegate? d) if (!InternalEqualTypes(this, d)) throw new ArgumentException(SR.Arg_DlgtTypeMis); - if (IsDynamicDelegate()) - throw new InvalidOperationException(); - int followCount = 1; Wrapper[]? followList = d._helperObject as Wrapper[]; if (followList != null)