-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[runtime] Allow IntPtr
for native objects in the dynamic registrar. Fixes #15708
#15712
Conversation
…ixes xamarin#15708 Allow code like this ```csharp [DllImport(Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSendSuper") static extern IntPtr IntPtr_objc_msgSendSuper(IntPtr receiver, IntPtr selector); [DllImport(Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSendSuper")] static extern void void_objc_msgSendSuper(IntPtr receiver, IntPtr selector, IntPtr arg); [Export("selectedTextRange")] public new IntPtr SelectedTextRange { get { return IntPtr_objc_msgSendSuper(SuperHandle, Selector.GetHandle("selectedTextRange")); } set => void_objc_msgSendSuper(SuperHandle, Selector.GetHandle("setSelectedTextRange:"), value); } ``` to work on the dynamic registrar since it already work with the static one. This allows the simulators (which defaults to dynamic) to share the same code which is useful for implementing a workaround for related issue xamarin#15677.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
if (!strcmp (fullname, "System.IntPtr")) { | ||
returnValue = *(void **) mono_object_unbox (retval); | ||
} else { | ||
xamarin_assertion_message ("Don't know how to marshal a return value of type '%s.%s'. Please file a bug with a test case at https://github.com/xamarin/xamarin-macios/issues/new\n", mono_class_get_namespace (r_klass), mono_class_get_name (r_klass)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have the fullname
, why not change the assertion message to:
xamarin_assertion_message ("Don't know how to marshal a return value of type '%s', Please Please file a bug with a test case at https://github.com/xamarin/xamarin-macios/issues/new\n", full name);
On a side note, I wonder if this won't be immediately stale with the .NET 6 transition to NativeHandle
instead of IntPtr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both good points @stephen-hawley I'll address them shortly. Thanks!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
runtime/trampolines.m
Outdated
#if DOTNET | ||
if (!strcmp (fullname, "System.IntPtr") || !strcmp (fullname, "ObjCRuntime.NativeHandle")) { | ||
#else | ||
if (!strcmp (fullname, "System.IntPtr")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two functions that are much faster and simpler: xamarin_is_class_intptr
and xamarin_is_class_nativehandle
, no need to compute a full type name nor compare strings.
runtime/trampolines.m
Outdated
@@ -201,7 +201,17 @@ | |||
} | |||
} | |||
} else { | |||
xamarin_assertion_message ("Don't know how to marshal a return value of type '%s.%s'. Please file a bug with a test case at https://github.com/xamarin/xamarin-macios/issues/new\n", mono_class_get_namespace (r_klass), mono_class_get_name (r_klass)); | |||
char *fullname = xamarin_class_get_full_name (r_klass, exception_gchandle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last little bit - since fullname
is only used in the error and @rolfbjarne implies that it's more costly than the xamarin_is_class_
tests, how about moving the allocation and deallocation into the else
clause so that the price only gets paid in the failing case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted the assertion to the original code as it did not need (extra) allocation, inside the caller, and still produced the same output.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
❗ API diff vs stable (Breaking changes)Legacy Xamarin (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
.NET (:heavy_exclamation_mark: Breaking changes :heavy_exclamation_mark:)
✅ Generator diffGenerator diff is empty Pipeline on Agent |
💻 [PR Build] Tests on macOS Mac Catalina (10.15) passed 💻✅ All tests on macOS Mac Catalina (10.15) passed. Pipeline on Agent |
❌ [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌Failed tests are:
Pipeline on Agent |
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: simulator tests 0 tests crashed, 7 tests failed, 221 tests passed. Failures❌ introspection tests
Html Report (VSDrops) Download ❌ mononative tests
Html Report (VSDrops) Download ❌ monotouch tests
Html Report (VSDrops) Download Successes✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Test failures are unrelated (https://github.com/xamarin/maccore/issues/581, https://github.com/xamarin/maccore/issues/2558) |
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
…ashes Pro: It does not break app compatibility, selection works Con: This does not work _currently_ with the dynamic registrar [1] which is the default when building for iOS simulators. OTOH there's a workaround for that [2]. [1] Unless building with the iOS SDK for Xcode 14 (currently only previews) once xamarin/xamarin-macios#15712 is merged [2] Adding `--registrar=static` to the simulator builds will fix this, sadly build times will be longer (so better use [1] asap)
Allow code like this
to work on the dynamic registrar since it already work with the static one.
This allows the simulators (which defaults to dynamic) to share the same code which is useful for implementing a workaround for related issue #15677.