Don't block non-blittable pointer types in P/Invokes. (#1866)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Thu, 23 Jan 2020 00:22:09 +0000 (16:22 -0800)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2020 00:22:09 +0000 (16:22 -0800)
commit53e8fea8f28481b0ce07185e48402ec5c9802577
tree1173153b98fc744b9babfc66daf5461e3d89a028
parenta680821f079c36dacbbdf96596215440519a2dcb
Don't block non-blittable pointer types in P/Invokes. (#1866)

* Don't block non-blittable pointer types in P/Invokes.

Don't block non-blittable pointer types in P/Invokes. If you're using pointers in interop you're already using unsafe code so we're going to assume you know what you're doing. C# won't let you form a pointer to a reference, so there's no risk of passing an object reference directly to native unless you're writing IL directly.

Fixes dotnet/coreclr#27800

* Delete unused resources.

* Apply fix to managed type system as well.

* Add positive test for nonblittable pointers. Remove negative tests that were in GenericTest.
24 files changed:
src/coreclr/src/dlls/mscorrc/mscorrc.rc
src/coreclr/src/dlls/mscorrc/resource.h
src/coreclr/src/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs
src/coreclr/src/vm/mlinfo.cpp
src/coreclr/tests/src/Interop/CMakeLists.txt
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableB.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableC.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableD.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableF.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableL.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.NullableU.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point1B.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point1C.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point2B.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point2C.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point3B.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point3C.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point4B.cs
src/coreclr/tests/src/Interop/PInvoke/Generics/GenericsTest.Point4C.cs
src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/CMakeLists.txt [new file with mode: 0644]
src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/NonBlittablePointer.csproj [moved from src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/PInvokePointerTest.csproj with 75% similarity]
src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/NonBlittablePointerNative.cpp [new file with mode: 0644]
src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/PInvokePointerTest.cs [deleted file]
src/coreclr/tests/src/Interop/PInvoke/Primitives/Pointer/Program.cs [new file with mode: 0644]