Repository navigation
Closed
Description
When we did not need to worry about NativeAOT we could write a binding in the following way:
[Mac (14,0)]
[Export ("presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:hasFullSizeContent:")]
void Present (NSViewController viewController, CGRect positioningRect, NSView positioningView, NSRectEdge preferredEdge, NSPopoverBehavior behavior, byte hasFullSizeContent);Yet, now the above code will result in the following cecil test failure:
Cecil.Tests.BlittablePInvokes.CheckForNonBlittablePInvokes: Failures: In the file tests/cecil-tests/BlittablePInvokes.cs, read the guide carefully.
Expected: <empty>
But was: < ("ObjCRuntime.NativeHandle ObjCRuntime.Messaging::NativeHandle_objc_msgSend_nfloat_bool(System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat,System.Boolean)", <string.Empty>), ("ObjCRuntime.NativeHandle ObjCRuntime.Messaging::NativeHandle_objc_msgSendSuper_nfloat_bool(System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat,System.Boolean)", <string.Empty>), ("System.Void ObjCRuntime.Messaging::void_objc_msgSend_NativeHandle_CGRect_NativeHandle_UIntPtr_IntPtr_bool(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle,CoreGraphics.CGRect,ObjCRuntime.NativeHandle,System.UIntPtr,System.IntPtr,System.Boolean)", <string.Empty>), ("System.Void ObjCRuntime.Messaging::void_objc_msgSendSuper_NativeHandle_CGRect_NativeHandle_UIntPtr_IntPtr_bool(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle,CoreGraphics.CGRect,ObjCRuntime.NativeHandle,System.UIntPtr,System.IntPtr,System.Boolean)", <string.Empty>) **>**
You can see that one of the offending methods is:
ObjCRuntime.Messaging::void_objc_msgSend_NativeHandle_CGRect_NativeHandle_UIntPtr_IntPtr_bool(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle,CoreGraphics.CGRect,ObjCRuntime.NativeHandle,System.UIntPtr,System.IntPtr,System.Boolean)"A workaround to the issue is to change the binding to the following:
[Internal]
[Mac (14,0)]
[Export ("presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:hasFullSizeContent:")]
void _Present (NSViewController viewController, CGRect positioningRect, NSView positioningView, NSRectEdge preferredEdge, NSPopoverBehavior behavior, byte hasFullSizeContent);
[Mac (14,0)]
[Wrap ("_Present (viewController, positioningRect, positioningView, preferredEdge, behavior, hasFullSizeContent ? (byte) 1 : (byte) 0)")]
void Present (NSViewController viewController, CGRect positioningRect, NSView positioningView, NSRectEdge preferredEdge, NSPopoverBehavior behavior, bool hasFullSizeContent);NONE of or users expect to have to change all their bindings that take a boolean to take a byte and do a wrap with hasFullSizeContent ? (byte) 1 : (byte) 0.
Either the test is wrong or the generator needs to be able to deal with the boolean parameter without asking the user to do the conversion to a byte.
Activity
rolfbjarne commentedon Aug 10, 2023
We have a rather long list of known failures:
https://github.com/xamarin/xamarin-macios/blob/571cd456275909f6f87d132b45bd4e55ecec3e0f/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs#L19
Most of these are due to limitations in the generator that needs to be fixed, so just add the new signature there.
Keeping this bug open to fix the generator (and the corresponding known failures).
[src] Make all generated P/Invokes use blittable signatures. Fixes do…
[src] Make all generated P/Invokes use blittable signatures. Fixes do…
[src] Make all generated P/Invokes use blittable signatures. Fixes #1…