Uh oh!
There was an error while loading. Please reload this page.
Move bulk of the CoreCLR delegate implementation to Delegate.CoreCLR.cs - #130738
Conversation
jkotas
commented
Jul 14, 2026
- Matches structure of NativeAOT delegate impletation
- Avoids Unsafe.As casts
- Avoids C# "new slots" that are breaking code produced by managed C++. Fixes app compat bug [dotnet-sdk-11.0.100-preview.7.26360.111] Autodesk Revit 2026 launch failed with error: System.MethodAccessException: Attempt by method 'Autodesk.Revit.ApplicationServices.Application.add_ApplicationInitia... #130612.
- Matches structure of NativeAOT delegate impletation - Avoids Unsafe.As casts - Avoids C# "new slots" that are breaking code produced by managed C++. Fixes app compat bug dotnet#130612.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Tagging subscribers to this area: @steveisok, @dotnet/area-system-reflection |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Refactors delegate implementation across CoreCLR / Mono / shared CoreLib sources by moving multicast-combine/remove and delegate-constructor logic into Delegate.CoreCLR.cs, aligning structure with other runtimes and addressing an app-compat regression involving delegate member accessibility/resolution.
Changes:
- CoreCLR: move multicast combine/remove + delegate ctor helpers from
MulticastDelegate.CoreCLR.csintoDelegate.CoreCLR.cs, and update VM binders/callers to referenceSystem.Delegateinstead ofSystem.MulticastDelegate. - Mono: avoid hidden
newmembers onMulticastDelegateby renaming internal helpers and routing throughDelegate(and switchTargetto useGetTarget()). - Shared: move COM visibility attributes onto the shared
Delegate/MulticastDelegatedefinitions and unify delegate serialization failure toSerializationException.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mono/System.Private.CoreLib/src/System/MulticastDelegate.Mono.cs | Removes hidden new members (serialization + target) and renames internal helpers to avoid name collisions. |
| src/mono/System.Private.CoreLib/src/System/Delegate.Mono.cs | Routes Target/combine/remove/invocation-list through non-colliding helpers on MulticastDelegate. |
| src/libraries/System.Private.CoreLib/src/System/MulticastDelegate.cs | Adds COM visibility attributes in shared source and declares ISerializable on the shared type. |
| src/libraries/System.Private.CoreLib/src/System/Delegate.cs | Adds COM visibility attributes and changes GetObjectData to throw SerializationException. |
| src/coreclr/vm/corelib.h | Moves delegate ctor method bindings from MULTICAST_DELEGATE to DELEGATE. |
| src/coreclr/vm/comdelegate.cpp | Updates delegate construction to bind to METHOD__DELEGATE__CTOR_* methods. |
| src/coreclr/vm/appdomain.cpp | Removes CLASS__MULTICAST_DELEGATE from the reflection-invocation skip list. |
| src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | Drops compilation of MulticastDelegate.CoreCLR.cs (logic moved elsewhere). |
| src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.CoreCLR.cs | Deleted; prior CoreCLR multicast/ctor implementation relocated. |
| src/coreclr/System.Private.CoreLib/src/System/Delegate.CoreCLR.cs | Becomes the primary home for multicast combine/remove and delegate ctor helpers in CoreCLR. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs | Removes an unused internal helper and makes HasSingleTargetpartial for consistency. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MichalPetryka
left a comment
There was a problem hiding this comment.
Some other usings may be not needed now.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tannergooding
left a comment
There was a problem hiding this comment.
Changes LGTM. Just a couple small questions
Uh oh!
There was an error while loading. Please reload this page.
jkotas
commented
Jul 15, 2026
@MichalPetryka You can start working on the follow up optimizations now |