From 76305b7829aee79a4b31381c6f706329dc197b21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 20:04:18 +0000 Subject: [PATCH 1/3] Initial plan From 9695953ae3ac0c0f4fe71742d5bd3c6df767abae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 20:06:21 +0000 Subject: [PATCH 2/3] Add CreateTestClass and DeleteTestClass P/Invoke declarations --- .../csharp/PInvokeLibManaged/NativeMethods.cs | 6 ++++++ .../vb/PInvokeLibManaged/NativeMethods.vb | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/NativeMethods.cs b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/NativeMethods.cs index 95ad89611b78d..62856b31866d4 100644 --- a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/NativeMethods.cs +++ b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/NativeMethods.cs @@ -86,5 +86,11 @@ internal static extern int TestArrayOfStructs2( [DllImport("PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] internal static extern void TestArrayInStruct(ref MyArrayStruct myStruct); + + [DllImport("PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] + internal static extern unsafe void* CreateTestClass(); + + [DllImport("PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] + internal static extern unsafe void DeleteTestClass(void* instance); } // diff --git a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/vb/PInvokeLibManaged/NativeMethods.vb b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/vb/PInvokeLibManaged/NativeMethods.vb index bbccef564a151..3234efc5ef2be 100644 --- a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/vb/PInvokeLibManaged/NativeMethods.vb +++ b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/vb/PInvokeLibManaged/NativeMethods.vb @@ -90,5 +90,13 @@ Friend Class NativeMethods Friend Shared Sub TestArrayInStruct(ByRef myStruct As MyArrayStruct) End Sub + + + Friend Shared Function CreateTestClass() As IntPtr + End Function + + + Friend Shared Sub DeleteTestClass(ByVal instance As IntPtr) + End Sub End Class ' From b3626d9cd1a76b906a7a5dc8430d475f35c35230 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 21:02:09 +0000 Subject: [PATCH 3/3] Add AllowUnsafeBlocks=true to PInvokeLibManaged.csproj --- .../csharp/PInvokeLibManaged/PInvokeLibManaged.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/PInvokeLibManaged.csproj b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/PInvokeLibManaged.csproj index ed9781c223ab9..598db52879f65 100644 --- a/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/PInvokeLibManaged.csproj +++ b/docs/standard/native-interop/snippets/marshalling-data-with-platform-invoke/csharp/PInvokeLibManaged/PInvokeLibManaged.csproj @@ -5,6 +5,7 @@ net10.0 enable enable + true