Skip to content

Commit 2950a84

Browse files
authored
Discourage marshalled delegates (#46552)
1 parent 67516b3 commit 2950a84

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/standard/native-interop/best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The guidance in this section applies to all interop scenarios.
1818
- ✔️ DO define P/Invoke and function pointer signatures that match the C function's arguments.
1919
- ✔️ DO use .NET types that map closest to the native type. For example, in C#, use `uint` when the native type is `unsigned int`.
2020
- ✔️ DO prefer expressing higher level native types using .NET structs rather than classes.
21-
- ✔️ DO prefer using function pointers, as opposed to `Delegate` types, when passing callbacks to unmanaged functions in C#.
21+
- ✔️ DO prefer using function pointers and <xref:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute> as opposed to `Delegate` types, when passing callbacks to unmanaged functions in C#. For more information, see <xref:System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(System.Delegate)>.
2222
- ✔️ DO use `[In]` and `[Out]` attributes on array parameters.
2323
- ✔️ DO only use `[In]` and `[Out]` attributes on other types when the behavior you want differs from the default behavior.
2424
- ✔️ CONSIDER using <xref:System.Buffers.ArrayPool%601?displayProperty=nameWithType> to pool your native array buffers.

0 commit comments

Comments
 (0)