Skip to content

Commit

Permalink
Allow passing IntPtr values with UnmanagedType.AsAny. (dotnet#2039)
Browse files Browse the repository at this point in the history
This is used by the SplashScreen class of WindowsBase in .NET Core to pass a NULL pointer.

Co-authored-by: Vincent Povirk <[email protected]>
  • Loading branch information
2 people authored and akoeplinger committed Jan 27, 2020
1 parent db70456 commit 653b322
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mono/mono/metadata/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/mono/mono/tests/libtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}
Expand Down
3 changes: 3 additions & 0 deletions src/mono/mono/tests/pinvoke2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ public static int test_0_asany () {
catch (ArgumentException) {
}

if (mono_test_asany (new IntPtr(5), 5) != 0)
return 7;

return 0;
}

Expand Down

0 comments on commit 653b322

Please sign in to comment.