CHAPTER 15 TYPE REFLECTION, LATE BINDING, AND ATTRIBUTE-BASED PROGRAMMING
TypeDef #2 (02000003)
------------------------------------------------------TypDefName: CarLibrary.EngineState (02000003)
Flags
: [Public] [AutoLayout] [Class] [Sealed] [AnsiClass] (00000101)
Extends
: 01000001 [TypeRef] System.Enum
Field #1 (04000006)
------------------------------------------------------Field Name: value__ (04000006)
Flags
: [Public] [SpecialName] [RTSpecialName] (00000606)
CallCnvntn: [FIELD]
Field type: I4
Field #2 (04000007)
------------------------------------------------------Field Name: engineAlive (04000007)
Flags
: [Public] [Static] [Literal] [HasDefault]
DefltValue: (I4) 0
CallCnvntn: [FIELD]
Field type: ValueClass CarLibrary.EngineState
...
(00008056)
Here, the TypDefName token is used to establish the name of the given type, which in this case is the
custom CarLibrary.EngineState enum. The Extends metadata token is used to document the base type of a
given .NET type (in this case, the referenced type, System.Enum). Each field of an enumeration is marked
using the Field #n token. For brevity, I have simply listed the metadata for
CarLibrary.EngineState.engineAlive.
Viewing (Partial) Metadata for the Car Type
Here is a partial dump of the Car class that illustrates the following:
•
How fields are defined in terms of .NET metadata
•
How methods are documented via .NET metadata
•
How an automatic property is represented in .NET metadata
TypeDef #3 (02000004)
------------------------------------------------------TypDefName: CarLibrary.Car (02000004)
Flags : [Public] [AutoLayout] [Class] [Abstract]
[AnsiClass] [BeforeFieldInit] (00100081)
Extends : 01000002 [TypeRef] System.Object
...
Field #2 (0400000a)
------------------------------------------------------Field Name: k__BackingField (0400000A)
Flags
: [Private] (00000001)
CallCnvntn: [FIELD]
Field type: String
...
557