Skip to content

Latest commit

 

History

History
70 lines (36 loc) · 4.45 KB

ii.22.10-customattribute-0x0c.md

File metadata and controls

70 lines (36 loc) · 4.45 KB

II.22.10 CustomAttribute: 0x0C

The CustomAttribute table has the following columns:

  • Parent (an index into a metadata table that has an associated HasCustomAttributeII.24.2.6) coded index).

  • Type (an index into the MethodDef or MemberRef table; more precisely, a CustomAttributeTypeII.24.2.6) coded index).

  • Value (an index into the Blob heap).

The CustomAttribute table stores data that can be used to instantiate a Custom Attribute (more precisely, an object of the specified Custom Attribute class) at runtime. The column called Type is slightly misleading—it actually indexes a constructor method—the owner of that constructor method is the Type of the Custom Attribute. A row in the CustomAttribute table for a parent is created by the .custom attribute, which gives the value of the Type column and optionally that of the Value column (§II.21).

This contains informative text only.

All binary values are stored in little-endian format (except for PackedLen items, which are used only as a count for the number of bytes to follow in a UTF8 string).

  1. No CustomAttribute is required; that is, Value is permitted to be null.

  2. Parent can be an index into any metadata table, except the CustomAttribute table itself [ERROR]

  3. Type shall index a valid row in the Method or MemberRef table. That row shall be a constructor method (for the class of which this information forms an instance) [ERROR]

  4. Value can be null or non-null.

  5. If Value is non-null, it shall index a 'blob' in the Blob heap [ERROR]

  6. The following rules apply to the overall structure of the Value 'blob' (§II.23.3):

    • Prolog shall be 0x0001 [ERROR]

    • There shall be as many occurrences of FixedArg as are declared in the Constructor method [ERROR]

    • NumNamed can be zero or more

    • There shall be exactly NumNamed occurrences of NamedArg [ERROR]

    • Each NamedArg shall be accessible by the caller [ERROR]

    • If NumNamed = 0 then there shall be no further items in the CustomAttrib [ERROR]

  7. The following rules apply to the structure of FixedArgII.23.3):

    • If this item is not for a vector (a single-dimension array with lower bound of 0), then there shall be exactly one Elem [ERROR]

    • If this item is for a vector, then:

    • NumElem shall be 1 or more [ERROR]

    • This shall be followed by NumElem occurrences of Elem [ERROR]

  8. The following rules apply to the structure of ElemII.23.3):

    • If this is a simple type or an enum (see §II.23.3 for how this is defined), then Elem consists simply of its value [ERROR]

    • If this is a string or a Type, then Elem consists of a SerStringPackedLen count of bytes, followed by the UTF8 characters [ERROR]

    • If this is a boxed simple value type (bool, char, float32, float64, int8, int16, int32, int64, unsigned int8, unsigned int16, unsigned int32, or unsigned int64), then Elem consists of the corresponding type denoter (ELEMENT_TYPE_BOOLEAN, ELEMENT_TYPE_CHAR, ELEMENT_TYPE_I1, ELEMENT_TYPE_U1, ELEMENT_TYPE_I2, ELEMENT_TYPE_U2, ELEMENT_TYPE_I4, ELEMENT_TYPE_U4, ELEMENT_TYPE_I8, ELEMENT_TYPE_U8, ELEMENT_TYPE_R4, or ELEMENT_TYPE_R8), followed by its value. [ERROR]

  9. The following rules apply to the structure of NamedArg (§II.23.3):

    • A NamedArg shall begin with the single byte FIELD (0x53) or PROPERTY (0x54) for identification [ERROR]

    • If the parameter kind is a boxed simple value type, then the type of the Field or Property is one of ELEMENT_TYPE_BOOLEAN, ELEMENT_TYPE_CHAR, ELEMENT_TYPE_I1, ELEMENT_TYPE_U1, ELEMENT_TYPE_I2, ELEMENT_TYPE_U2, ELEMENT_TYPE_I4, ELEMENT_TYPE_U4, ELEMENT_TYPE_I8, ELEMENT_TYPE_U8, ELEMENT_TYPE_R4, ELEMENT_TYPE_R8, ELEMENT_TYPE_STRING, or the constant 0x50 (for an argument of type System.Type) [ERROR]

    • The name of the Field or Property, respectively with the previous item, is stored as a SerStringPackedLen count of bytes, followed by the UTF8 characters of the name [ERROR]

    • A NamedArg is a FixedArg (see above) [ERROR]

End informative text.