Skip to content

Commit

Permalink
Add note about internal representation of .NET runtime types (#44672)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas authored Feb 4, 2025
1 parent 2029609 commit d2cb2d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/standard/native-interop/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ Pointers to structs in definitions must either be passed by `ref` or use `unsafe

✔️ DO use the C# `sizeof()` instead of `Marshal.SizeOf<MyStruct>()` for blittable structures to improve performance.

❌ DON'T depend on internal representation of struct types exposed by .NET runtime libraries unless it is explicitly documented.

❌ AVOID using classes to express complex native types through inheritance.

❌ AVOID using `System.Delegate` or `System.MulticastDelegate` fields to represent function pointer fields in structures.
Expand Down

0 comments on commit d2cb2d1

Please sign in to comment.