Skip to content

Discourage marshalled delegates #46552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/standard/native-interop/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <xref:System.Runtime.InteropServices.Marshal.Marshal.GetFunctionPointerForDelegate>.
- ✔️ 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 <xref:System.Buffers.ArrayPool%601?displayProperty=nameWithType> to pool your native array buffers.
Expand Down
Loading