Skip to content
Merged
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
3 changes: 2 additions & 1 deletion docs/standard/native-interop/best-practices.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Native interoperability best practices - .NET
description: Learn the best practices for interfacing with native components in .NET.
ms.date: 04/08/2024
ms.date: 07/09/2025
---
# Native interoperability best practices

Expand All @@ -15,6 +15,7 @@ The guidance in this section applies to all interop scenarios.
- There are cases when using `[DllImport]` is appropriate. A code analyzer with ID [SYSLIB1054](../../fundamentals/syslib-diagnostics/syslib1050-1069.md) tells you when that's the case.
- ✔️ DO use the same naming and capitalization for your methods and parameters as the native method you want to call.
- ✔️ CONSIDER using the same naming and capitalization for constant values.
- ✔️ DO define P/Invoke and function pointer signatures that match the C function's arguments.
- ✔️ 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#.
Expand Down