Default marshaling rules
Explicit JsMarshalAs overrides legal defaults. CLR plans contain no engine SDK values; wrapper/view/borrow semantics are engine-independent.
Marshaling specification
Marshaling is defined by CLR slot type, direction, byref role, and policy. Mono/IL2CPP and V8/HostJs must expose the same results.
JsMarshalAs and legal policies
1. Positions and values
ref, in, and out marshaling
1. Directions
OpaqueValue borrowing
OpaqueValue exposes controlled access to CLR parameter storage during one C#→JS call. It is a borrowed token, not a persistent address or ordinary CLR wrapper.
Struct marshaling
1. Representations
Class and interface marshaling
1. Default forms
Array marshaling
CLR arrays default to ByObj wrappers with identity and roots. SZArrays, mdarrays, byte[], and ordinary JS Arrays remain distinct.
Enum marshaling
Enums default to integral number, not wrappers or bigint—even with Int64/UInt64 underlying types.
Delegate and function marshaling
This defines both directions between CLR delegates and JS functions. There is no special event marshaler: use add/remove. Mono uses cached Expression Emit; IL2CPP uses available compiled calling bridges.
Pointers and restricted types
1. Numeric pointers versus tokens