You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CoreCLR] Dynamically build custom delegate types to support [Export] (#10503)
The problem is that the Marshal.GetFunctionPointerForDelegate method
does not work with delegates with generic types, such as `Action<...>`
or `Func<...>` (context:
dotnet/runtime#32963), which was the case of
all the delegates created in `Mono.Android.Export` through
`DynamicMethod`.
This PR replaces the use of these generic delegate types with
dynamically built non-generic types. It is based on an existing
implementation in java-interop (see [here][0]).
The CoreCLR is able to marshal the delegates built with these types to
function pointers just fine.
In a previous attempt at fixing this issue (#10493), I chose a
solution which modified the shape of `JniNativeMethodRegistration`
which would be an ABI breaking change (dotnet/java-interop#1364). This
implementation is much simpler and doesn't cause the same problem.
Thanks to @jonpryor for steering me in this direction.
[0]: https://github.com/dotnet/java-interop/blob/02bceb03f7c07858590d930ef507745a88200a48/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs#L274-L311
// Based on https://github.com/dotnet/java-interop/blob/02bceb03f7c07858590d930ef507745a88200a48/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs#L274-L311
0 commit comments