Skip to content

Commit d2cb2d1

Browse files
authored
Add note about internal representation of .NET runtime types (#44672)
1 parent 2029609 commit d2cb2d1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ Pointers to structs in definitions must either be passed by `ref` or use `unsafe
400400

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

403+
❌ DON'T depend on internal representation of struct types exposed by .NET runtime libraries unless it is explicitly documented.
404+
403405
❌ AVOID using classes to express complex native types through inheritance.
404406

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

0 commit comments

Comments
 (0)