mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00
Add comment about using source-generated p/invokes to interop guidelines (#63350)
This commit is contained in:
parent
eed3a62e42
commit
4a1bcc3524
1 changed files with 6 additions and 0 deletions
|
@ -166,6 +166,12 @@ Using enums instead of partial, static classes can lead to needing lots of casts
|
|||
|
||||
When defining the P/Invoke signatures and structs, we follow the guidelines in the [interop best practices documentation](https://docs.microsoft.com/en-us/dotnet/standard/native-interop/best-practices).
|
||||
|
||||
The runtime repo makes use of [source-generated p/invokes](../design/features/source-generator-pinvokes.md) whenever possible (see [the compatibility doc](../design/libraries/DllImportGenerator/Compatibility.md) for unsupported scenarios). Methods should be marked `GeneratedDllImport` and be `static` and `partial`.
|
||||
|
||||
If implicit framework references are disabled (as is the case for most libraries projects), explicit references to the below are required for marshalling arrays:
|
||||
- `System.Memory`
|
||||
- `System.Runtime.CompilerServices.Unsafe`
|
||||
|
||||
## UNIX shims
|
||||
|
||||
Often, various UNIX flavors offer the same API from the point-of-view of compatibility with C/C++ source code, but they do not have the same ABI. e.g. Fields can be laid out differently, constants can have different numeric values, exports can be named differently, etc. There are not only differences between operating systems (Mac OS X vs. Ubuntu vs. FreeBSD), but also differences related to the underlying processor architecture (x64 vs. x86 vs. ARM).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue