From 0079b202c022a68ed17e39f058e8121a7a6be98e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:37:09 +0000 Subject: [PATCH 1/3] Initial plan From a3f95a35ff12e5e50d1aa57d7b908bf40547cd09 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:40:14 +0000 Subject: [PATCH 2/3] Add links to pinning examples in copying-and-pinning.md Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --- docs/framework/interop/copying-and-pinning.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/framework/interop/copying-and-pinning.md b/docs/framework/interop/copying-and-pinning.md index bef48f7e81b93..de78dab6624fe 100644 --- a/docs/framework/interop/copying-and-pinning.md +++ b/docs/framework/interop/copying-and-pinning.md @@ -1,7 +1,8 @@ --- title: "Copying and Pinning" description: Review how the interop marshaller can copy or pin data that's being marshalled. Copying data places a copy of data from one memory location into another location. -ms.date: 05/12/2022 +ms.date: 03/20/2026 +ai-usage: ai-assisted helpviewer_keywords: - "pinning, interop marshalling" - "copying, interop marshalling" @@ -19,7 +20,7 @@ Method arguments passed by value are marshalled to unmanaged code as values on t ![Diagram showing reference types passed by value and by reference.](./media/copying-and-pinning/interop-marshal-reference-pin.gif) -Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as , however you can also manually pin memory using the class. +Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as , however you can also manually pin memory using the class. For examples of manual pinning with `GCHandle`, see [Keeping managed objects alive](../../standard/native-interop/best-practices.md#keeping-managed-objects-alive) in the native interoperability best practices article. ## Formatted Blittable Classes @@ -78,3 +79,5 @@ When a is passed b - [Default Marshalling Behavior](default-marshalling-behavior.md) - [Directional Attributes](/previous-versions/dotnet/netframework-4.0/77e6taeh(v=vs.100)) - [Interop Marshaling](interop-marshalling.md) +- [Native interoperability best practices](../../standard/native-interop/best-practices.md) +- [fixed statement (C# reference)](../../csharp/language-reference/statements/fixed.md) From b23c0db3f8829114e7f29e1905997a559f01fb4d Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Fri, 20 Mar 2026 19:45:53 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Bill Wagner --- docs/framework/interop/copying-and-pinning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/framework/interop/copying-and-pinning.md b/docs/framework/interop/copying-and-pinning.md index de78dab6624fe..2116855415b69 100644 --- a/docs/framework/interop/copying-and-pinning.md +++ b/docs/framework/interop/copying-and-pinning.md @@ -20,7 +20,7 @@ Method arguments passed by value are marshalled to unmanaged code as values on t ![Diagram showing reference types passed by value and by reference.](./media/copying-and-pinning/interop-marshal-reference-pin.gif) -Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as , however you can also manually pin memory using the class. For examples of manual pinning with `GCHandle`, see [Keeping managed objects alive](../../standard/native-interop/best-practices.md#keeping-managed-objects-alive) in the native interoperability best practices article. +Pinning temporarily locks the data in its current memory location, thus keeping it from being relocated by the common language runtime's garbage collector. The marshaller pins data to reduce the overhead of copying and enhance performance. The type of the data determines whether it is copied or pinned during the marshalling process. Pinning is automatically performed during marshalling for objects such as . However you can also manually pin memory using the class. For examples of manual pinning with `GCHandle`, see [Keeping managed objects alive](../../standard/native-interop/best-practices.md#keeping-managed-objects-alive) in the native interoperability best practices article. ## Formatted Blittable Classes