From 248553f069b69f1a32159e1275c19e3149711894 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 3 Jun 2025 21:22:05 -0700 Subject: [PATCH] Discourage marshalled delegates --- docs/standard/native-interop/best-practices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard/native-interop/best-practices.md b/docs/standard/native-interop/best-practices.md index f0872908032c8..96d0357e41d93 100644 --- a/docs/standard/native-interop/best-practices.md +++ b/docs/standard/native-interop/best-practices.md @@ -17,7 +17,7 @@ The guidance in this section applies to all interop scenarios. - ✔️ CONSIDER using the same naming and capitalization for constant values. - ✔️ DO use .NET types that map closest to the native type. For example, in C#, use `uint` when the native type is `unsigned int`. - ✔️ DO prefer expressing higher level native types using .NET structs rather than classes. -- ✔️ DO prefer using function pointers, as opposed to `Delegate` types, when passing callbacks to unmanaged functions in C#. +- ✔️ DO prefer using function pointers and [`UnmanagedCallersOnlyAttribute`](xref:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute), as opposed to `Delegate` types, when passing callbacks to unmanaged functions in C#. For more information, see the . - ✔️ DO use `[In]` and `[Out]` attributes on array parameters. - ✔️ DO only use `[In]` and `[Out]` attributes on other types when the behavior you want differs from the default behavior. - ✔️ CONSIDER using to pool your native array buffers.