Ejemplo n.º 1
0
        static unsafe void InitializeCoreCLRBridge(InitializationOptions *options)
        {
            if (options->xamarin_objc_msgsend != IntPtr.Zero)
            {
                ObjectiveCMarshal.SetMessageSendCallback(ObjectiveCMarshal.MessageSendFunction.MsgSend, options->xamarin_objc_msgsend);
            }

            if (options->xamarin_objc_msgsend_super != IntPtr.Zero)
            {
                ObjectiveCMarshal.SetMessageSendCallback(ObjectiveCMarshal.MessageSendFunction.MsgSendSuper, options->xamarin_objc_msgsend_super);
            }

            if (options->xamarin_objc_msgsend_stret != IntPtr.Zero)
            {
                ObjectiveCMarshal.SetMessageSendCallback(ObjectiveCMarshal.MessageSendFunction.MsgSendStret, options->xamarin_objc_msgsend_stret);
            }

            if (options->xamarin_objc_msgsend_super_stret != IntPtr.Zero)
            {
                ObjectiveCMarshal.SetMessageSendCallback(ObjectiveCMarshal.MessageSendFunction.MsgSendSuperStret, options->xamarin_objc_msgsend_super_stret);
            }

            delegate * unmanaged <void> beginEndCallback            = (delegate * unmanaged <void>)options->reference_tracking_begin_end_callback;
            delegate * unmanaged <IntPtr, int> isReferencedCallback = (delegate * unmanaged <IntPtr, int>)options->reference_tracking_is_referenced_callback;
            delegate * unmanaged <IntPtr, void> trackedObjectEnteredFinalization = (delegate * unmanaged <IntPtr, void>)options->reference_tracking_tracked_object_entered_finalization;
            ObjectiveCMarshal.Initialize(beginEndCallback, isReferencedCallback, trackedObjectEnteredFinalization, UnhandledExceptionPropagationHandler);
        }
Ejemplo n.º 2
0
        static void Validate_ReferenceTrackingAPIs_InvalidArgs()
        {
            Console.WriteLine($"Running {nameof(Validate_ReferenceTrackingAPIs_InvalidArgs)}...");

            delegate * unmanaged <void> beginEndCallback;
            delegate * unmanaged <IntPtr, int> isReferencedCallback;
            delegate * unmanaged <IntPtr, void> trackedObjectEnteredFinalization;
            NativeObjCMarshalTests.GetExports(out beginEndCallback, out isReferencedCallback, out trackedObjectEnteredFinalization);

            Assert.Throws <ArgumentNullException>(
                () =>
            {
                ObjectiveCMarshal.Initialize(null, isReferencedCallback, trackedObjectEnteredFinalization, OnUnhandledExceptionPropagationHandler);
            });
            Assert.Throws <ArgumentNullException>(
                () =>
            {
                ObjectiveCMarshal.Initialize(beginEndCallback, null, trackedObjectEnteredFinalization, OnUnhandledExceptionPropagationHandler);
            });
            Assert.Throws <ArgumentNullException>(
                () =>
            {
                ObjectiveCMarshal.Initialize(beginEndCallback, isReferencedCallback, null, OnUnhandledExceptionPropagationHandler);
            });
            Assert.Throws <ArgumentNullException>(
                () =>
            {
                ObjectiveCMarshal.Initialize(beginEndCallback, isReferencedCallback, trackedObjectEnteredFinalization, null);
            });
            Assert.Throws <ArgumentNullException>(
                () =>
            {
                ObjectiveCMarshal.CreateReferenceTrackingHandle(null, out _);
            });
        }