Allow passing IntPtr values with UnmanagedType.AsAny. (#2039)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Mon, 27 Jan 2020 10:19:26 +0000 (05:19 -0500)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 27 Jan 2020 10:19:26 +0000 (11:19 +0100)
This is used by the SplashScreen class of WindowsBase in .NET Core to pass a NULL pointer.

Co-authored-by: Vincent Povirk <madewokherd@gmail.com>
src/mono/mono/metadata/marshal.c
src/mono/mono/tests/libtest.c
src/mono/mono/tests/pinvoke2.cs

index 35bfe50..d8411ee 100644 (file)
@@ -6210,6 +6210,7 @@ mono_marshal_asany_impl (MonoObjectHandle o, MonoMarshalNative string_encoding,
        case MONO_TYPE_I4:
        case MONO_TYPE_U4:
        case MONO_TYPE_PTR:
+       case MONO_TYPE_I:
        case MONO_TYPE_I1:
        case MONO_TYPE_U1:
        case MONO_TYPE_BOOLEAN:
index bd146f8..7a90aa9 100644 (file)
@@ -1834,6 +1834,9 @@ mono_test_asany (void *ptr, int what)
                        return 1;
                }
        }
+       case 5: {
+               return (*(intptr_t*)ptr == 5) ? 0 : 1;
+       }
        default:
                g_assert_not_reached ();
        }
index 07ae1dc..e9280db 100644 (file)
@@ -1088,6 +1088,9 @@ public unsafe class Tests {
                catch (ArgumentException) {
                }
 
+               if (mono_test_asany (new IntPtr(5), 5) != 0)
+                       return 7;
+
                return 0;
        }