From fe836ec75603a22af7ff9216af481cb78fcabe08 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 10 Feb 2017 17:24:49 +0100 Subject: [PATCH] [runtime] Unit test for Xamarin-47560 --- mono/tests/cominterop.cs | 8 ++++++++ mono/tests/libtest.c | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/mono/tests/cominterop.cs b/mono/tests/cominterop.cs index aecae40401d..4a5bd8fbc6f 100644 --- a/mono/tests/cominterop.cs +++ b/mono/tests/cominterop.cs @@ -251,6 +251,9 @@ public class Tests [DllImport ("libtest")] public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITestPresSig itest); + [DllImport ("libtest")] + public static extern int mono_test_marshal_array_ccw_itest (int count, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex=0)] ITest[] ppUnk); + [DllImport("libtest")] public static extern int mono_test_marshal_safearray_out_1dim_vt_bstr_empty ([MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)]out Array array); @@ -564,6 +567,11 @@ public class Tests mono_test_marshal_ccw_itest (test_pres_sig); + // test for Xamarin-47560 + var tests = new[] { test.Test }; + if (mono_test_marshal_array_ccw_itest (1, tests) != 0) + return 201; + #endregion // COM Callable Wrapper Tests #region SAFEARRAY tests diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c index b94b29d52fd..9950476e4ca 100644 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@ -3581,6 +3581,28 @@ mono_test_marshal_ccw_itest (MonoComObject *pUnk) return 0; } +// Xamarin-47560 +LIBTEST_API int STDCALL +mono_test_marshal_array_ccw_itest (int count, MonoComObject ** ppUnk) +{ + int hr = 0; + + if (!ppUnk) + return 1; + + if (count < 1) + return 2; + + if (!ppUnk[0]) + return 3; + + hr = ppUnk[0]->vtbl->SByteIn (ppUnk[0], -100); + if (hr != 0) + return 4; + + return 0; +} + /* * mono_method_get_unmanaged_thunk tests */ -- 2.25.1