The Field table has the following columns:
-
Flags (a 2-byte bitmask of type FieldAttributes, §II.23.1.5)
-
Name (an index into the String heap)
-
Signature (an index into the Blob heap)
Conceptually, each row in the Field table is owned by one, and only one, row in the TypeDef table. However, the owner of any row in the Field table is not stored anywhere in the Field table itself. There is merely a 'forward-pointer' from each row in the TypeDef table (the FieldList column), as shown in the following illustration.
The TypeDef table has rows 1–4. The first row in the TypeDef table corresponds to a pseudo type, inserted automatically by the CLI. It is used to denote those rows in the Field table corresponding to global variables. The Field table has rows 1—6. Type 1 (pseudo type for 'module') owns rows 1 and 2 in the Field table. Type 2 owns no rows in the Field table, even though its FieldList indexes row 3 in the Field table. Type 3 owns rows 3—5 in the Field table. Type 4 owns row 6 in the Field table. So, in the Field table, rows 1 and 2 belong to Type 1 (global variables); rows 3—5 belong to Type 3; row 6 belongs to Type 4.
Each row in the Field table results from a top-level .field directive (§II.5.10), or a .field directive inside a Type (§II.10.2). (For an example, see §II.14.5.)
This contains informative text only.
-
The Field table can contain zero or more rows
-
Each row shall have one, and only one, owner row in the TypeDef table [ERROR]
-
The owner row in the TypeDef table shall not be an Interface [CLS]
-
Flags shall have only those values set that are specified [ERROR]
-
The
FieldAccessMask
subfield of Flags shall contain precisely one ofCompilerControlled
,Private
,FamANDAssem
,Assembly
,Family
,FamORAssem
, orPublic
(§II.23.1.5) [ERROR] -
Flags can set either or neither of
Literal
orInitOnly
, but not both (§II.23.1.5) [ERROR] -
If Flags.
Literal
= 1 then Flags.Static
shall also be 1 (§II.23.1.5) [ERROR] -
If Flags.
RTSpecialName
= 1, then Flags.SpecialName
shall also be 1 (§II.23.1.5) [ERROR] -
If Flags.
HasFieldMarshal
= 1, then this row shall 'own' exactly one row in the FieldMarshal table (§II.23.1.5) [ERROR] -
If Flags.
HasDefault
= 1, then this row shall 'own' exactly one row in the Constant table (§II.23.1.5 [ERROR] -
If Flags.
HasFieldRVA
= 1, then this row shall 'own' exactly one row in the Field's RVA table (§II.23.1.5) [ERROR] -
Name shall index a non-empty string in the String heap [ERROR]
-
The Name string shall be a valid CLS identifier [CLS]
-
Signature shall index a valid field signature in the Blob heap [ERROR]
-
If Flags.
CompilerControlled
= 1 (§II.23.1.5), then this row is ignored completely in duplicate checking. -
If the owner of this field is the internally-generated type called
<Module>
, it denotes that this field is defined at module scope (commonly called a global variable). In this case:-
Flags.
Static
shall be 1 [ERROR] -
Flags.
MemberAccessMask
subfield shall be one ofPublic
,CompilerControlled
, orPrivate
(§II.23.1.5) [ERROR] -
module-scope fields are not allowed [CLS]
-
-
There shall be no duplicate rows in the Field table, based upon owner+Name+Signature (where owner is the owning row in the TypeDef table, as described above) (Note however that if Flags.
CompilerControlled
= 1, then this row is completely excluded from duplicate checking) [ERROR] -
There shall be no duplicate rows in the Field table, based upon owner+Name, where Name fields are compared using CLS conflicting-identifier-rules. So, for example,"
int i
" and "float i
" would be considered CLS duplicates. (Note however that if Flags.CompilerControlled
= 1, then this row is completely excluded from duplicate checking, as noted above) [CLS] -
If this is a field of an Enum then:
-
owner row in TypeDef table shall derive directly from
System.Enum
[ERROR] -
the owner row in TypeDef table shall have no other instance fields [CLS]
-
its Signature shall be one of
ELEMENT_TYPE_U1
,ELEMENT_TYPE_I2
,ELEMENT_TYPE_I4
, orELEMENT_TYPE_I8
(§II.23.1.16) [CLS]
-
-
its Signature shall be an integral type. [ERROR]
End informative text.