From 1f9798294f0f40ead6b69e5e1980761ca2464977 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 14:08:26 +0000 Subject: [PATCH 1/2] Initial plan From daa87426ceeab23936985e5a74827e019994a898 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 14:58:27 +0000 Subject: [PATCH 2/2] Remove dead NativeAOT dynamic delegate branch from Delegate Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com> --- .../src/System/Delegate.cs | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) 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)