The following table lists the CLI pseudo custom attributes. (Not all of these attributes are specified in this Standard, but all of their names are reserved and shall not be used for other purposes. For details on these attributes, see the documentation for the corresponding class in Partition IV.) They are defined in the namespaces System.Reflection
, System.Runtime.CompilerServices
, and System.Runtime.InteropServices
namespaces.
Attribute | Description |
---|---|
AssemblyAlgorithmIDAttribute |
Records the ID of the hash algorithm used (reserved only) |
AssemblyFlagsAttribute |
Records the flags for this assembly (reserved only) |
DllImportAttribute |
Provides information about code implemented within an unmanaged library |
FieldOffsetAttribute |
Specifies the byte offset of fields within their enclosing class or value type |
InAttribute |
Indicates that a method parameter is an [in] argument |
MarshalAsAttribute |
Specifies how a data item should be marshalled between managed and unmanaged code (see §II.23.4). |
MethodImplAttribute |
Specifies details of how a method is implemented |
OutAttribute |
Indicates that a method parameter is an [out] argument |
StructLayoutAttribute |
Allows the caller to control how the fields of a class or value type are laid out in managed memory |
These attributes affect bits and fields in metadata, as follows:
-
AssemblyAlgorithmIDAttribute
: sets the Assembly.HashAlgId field. -
AssemblyFlagsAttribute
: sets the Assembly.Flags field. -
DllImportAttribute
: sets the Method.Flags.PinvokeImpl
bit for the attributed method; also, adds a new row into the ImplMap table (setting MappingFlags, MemberForwarded, ImportName and ImportScope columns). -
FieldOffsetAttribute
: sets the FieldLayout.Offset value for the attributed field. -
InAttribute
: sets the Param.Flags.In
bit for the attributed parameter. -
MarshalAsAttribute
: sets the Field.Flags.HasFieldMarshal
bit for the attributed field (or the Param.Flags.HasFieldMarshal
bit for the attributed parameter); also enters a new row into the FieldMarshal table for both Parent and NativeType columns. -
MethodImplAttribute
: sets the Method.ImplFlags field of the attributed method. -
OutAttribute
: sets the Param.Flags.Out
bit for the attributed parameter. -
StructLayoutAttribute
: sets the TypeDef.Flags.LayoutMask
sub-field for the attributed type, and, optionally, the TypeDef.Flags.StringFormatMask
sub-field, the ClassLayout.PackingSize, and ClassLayout.ClassSize fields for that type.