The FieldMarshal table has two columns. It 'links' an existing row in the Field or Param table, to information in the Blob heap that defines how that field or parameter (which, as usual, covers the method return, as parameter number 0) shall be marshalled when calling to or from unmanaged code via PInvoke dispatch.
Note that FieldMarshal information is used only by code paths that arbitrate operation with unmanaged code. In order to execute such paths, the caller, on most platforms, would be installed with elevated security permission. Once it invokes unmanaged code, it lies outside the regime that the CLI can check—it is simply trusted not to violate the type system.
The FieldMarshal table has the following columns:
-
Parent (an index into Field or Param table; more precisely, a HasFieldMarshal (§II.24.2.6) coded index)
-
NativeType (an index into the Blob heap)
For the detailed format of the 'blob', see §II.23.4
A row in the FieldMarshal table is created if the .field directive for the parent field has specified a marshal attribute (§II.16.1).
This contains informative text only.
-
A FieldMarshal table can contain zero or more rows
-
Parent shall index a valid row in the Field or Param table (Parent values are encoded to say which of these two tables each refers to) [ERROR]
-
NativeType shall index a non-null 'blob' in the Blob heap [ERROR]
-
No two rows shall point to the same parent. In other words, after the Parent values have been decoded to determine whether they refer to the Field or the Param table, no two rows can point to the same row in the Field table or in the Param table [ERROR]
-
The following checks apply to the MarshalSpec 'blob' (§II.23.4):
-
NativeIntrinsic shall be exactly one of the constant values in its production (§II.23.4) [ERROR]
-
If
ARRAY
, then ArrayElemType shall be exactly one of the constant values in its production [ERROR] -
If
ARRAY
, then ParamNum can be zero -
If
ARRAY
, then ParamNum cannot be < 0 [ERROR] -
If
ARRAY
, and ParamNum > 0, then Parent shall point to a row in the Param table, not in the Field table [ERROR] -
If
ARRAY
, and ParamNum > 0, then ParamNum cannot exceed the number of parameters supplied to the MethodDef (or MethodRef if aVARARG
call) of which the parent Param is a member [ERROR] -
If
ARRAY
, then ElemMult shall be ≥ 1 [ERROR] -
If
ARRAY
and ElemMult ≠ 1 issue a warning, because it is probably a mistake [WARNING] -
If
ARRAY
and ParamNum = 0, then NumElem shall be ≥ 1 [ERROR] -
If
ARRAY
and ParamNum ≠ 0 and NumElem ≠ 0 then issue a warning, because it is probably a mistake [WARNING]
-
End informative text.