Skip to content

Conversation

@jkoritzinsky
Copy link
Member

Should unblock dotnet/efcore#36242

Implements workaround mentioned in dotnet/efcore#36242 (comment)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Prevents the NativeAOT-only unsafe accessor from being inlined by marking the extern CreateObjectArrayDelegate method with NoInlining, addressing a workaround needed by EF Core.

  • Added [MethodImpl(MethodImplOptions.NoInlining)] to the static extern call site.
  • Targets the CreateObjectArrayDelegate method in DelegateHelpers to ensure it isn’t inlined by the JIT/AOT compiler.
Comments suppressed due to low confidence (1)

src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs:33

  • [nitpick] Add a brief comment above this attribute to explain why NoInlining is required (e.g., to prevent inlining of the NativeAOT-only unsafe accessor), providing context for future maintainers.
[MethodImpl(MethodImplOptions.NoInlining)]

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @cston
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Jun 13, 2025

There may be a few more that deserve the same treatment:

[return: UnsafeAccessorType("System.Windows.Forms.ComponentModel.Com2Interop.ComNativeDescriptor, System.Windows.Forms")]
static extern object CreateComNativeDescriptor();
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "GetDefaultInstance")]
[return: UnsafeAccessorType("System.Security.Principal.WindowsPrincipal, System.Security.Principal.Windows")]

An alternative for this one is wrap the caller with #if TARGET_WINDOWS instead of catching and rethrowing an exception.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jkoritzinsky
Copy link
Member Author

/ba-g wasm build failure is unrelated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants