Repository navigation
Share more of RuntimeCustomAttributeData between CoreCLR and native AOT - #136837
Merged
MichalStrehovsky merged 4 commits intoNov 3, 2026
Merged
MichalStrehovsky merged 4 commits into
MichalStrehovsky merged 4 commits into
Conversation
Move the CoreCLR decoding helpers and CustomAttributeDataParser into shared CoreLib sources. Use ResolutionScope and conditionalize NativeAOT metadata handling while retaining CoreCLR's existing behavior. Co-authored-by: Copilot <[email protected]> Copilot-Session: 44ca18c9-11a3-4f9d-8842-e92a20a377ba
Move CoreCLR attribute activation and argument readers into shared CoreLib sources. Add NativeAOT's trusted constructor-only byref invocation and GC-reporting adapters while preserving CoreCLR behavior. Align NativeAOT constructor exception propagation with CoreCLR. Co-authored-by: Copilot <[email protected]> Copilot-Session: 44ca18c9-11a3-4f9d-8842-e92a20a377ba
|
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. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The NativeAOT change introduces ambiguous property resolution for null enum-array properties that hide inherited properties of a different type, causing attribute creation to fail and requiring type-aware lookup plus a regression test.
1 open issue
What changed in this PR
This PR consolidates custom-attribute parsing and activation in shared CoreLib code for CoreCLR and NativeAOT, with the intent of preserving CoreCLR behavior.
Changes:
- Moves parsing and activation logic into the shared implementation, retaining runtime-specific metadata handling.
- Adds NativeAOT support for direct-by-reference constructor invocation and shared GC reporting.
- Aligns NativeAOT constructor exception propagation with CoreCLR and expands tests to cover parameterless constructors.
| File | Description |
|---|---|
src/libraries/System.Runtime/tests/System.Reflection.Tests/CustomAttributeTests.cs |
Tests unwrapped exceptions from both constructor forms. |
src/libraries/System.Private.CoreLib/src/System/Runtime/GCFrameRegistration.cs |
Adds NativeAOT GC registration wrappers. |
src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs |
Hosts shared attribute parsing and activation. |
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.CoreCLR.cs |
Removes logic moved to shared CoreLib. |
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/MethodInvokers/InstanceMethodInvoker.cs |
Implements direct-by-reference constructor activation. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.NativeAot.cs |
Removes superseded NativeAOT parsing and activation. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/MethodInfos/RuntimeConstructorInfo.cs |
Caches constructor argument types. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/ThunkedApis.cs |
Adds adapters required by shared activation. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs |
Adds trusted by-reference constructor invocation. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/ActivatorImplementation.cs |
Makes constructor exception wrapping configurable. |
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Reflection/Core/Execution/MethodBaseInvoker.cs |
Defines the direct-by-reference activation entry point. |
Review effort: Balanced
MichalStrehovsky
commented
Nov 2, 2026
Replace the helper-level suppression with a DynamicallyAccessedMembers contract. The custom attribute caller already carries the relevant suppression. Co-authored-by: Copilot <[email protected]> Copilot-Session: 44ca18c9-11a3-4f9d-8842-e92a20a377ba
jkotas
reviewed
Nov 2, 2026
Remove forced inlining and the redundant prolog accessor, return RuntimeType directly from NativeAOT type-value decoding, and assert the validated constructor signature invariant in direct byref invocation. Co-authored-by: Copilot <[email protected]> Copilot-Session: 44ca18c9-11a3-4f9d-8842-e92a20a377ba
jkotas
approved these changes
Nov 2, 2026
agocke
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Now that the custom attribute blob has the same shape, we can share more of the parsing and activation.
This is a no-diff change for CoreCLR side, the lines should be identical, just moved to the shared file. The only exception is the RuntimeModule -> ResolutionScope renaming.