Free mag vol1 | Page 616

CHAPTER 15  TYPE REFLECTION, LATE BINDING, AND ATTRIBUTE-BASED PROGRAMMING Method #1 (06000001) ------------------------------------------------------MethodName: get_PetName (06000001) Flags : [Public] [HideBySig] [ReuseSlot] [SpecialName] RVA : 0x000020d0 ImplFlags : [IL] [Managed] (00000000) CallCnvntn: [DEFAULT] hasThis ReturnType: String No arguments. (00000886) ... Method #2 (06000002) ------------------------------------------------------MethodName: set_PetName (06000002) Flags : [Public] [HideBySig] [ReuseSlot] [SpecialName] (00000886) RVA : 0x000020e7 ImplFlags : [IL] [Managed] (00000000) CallCnvntn: [DEFAULT] hasThis ReturnType: Void 1 Arguments Argument #1: String 1 Parameters (1) ParamToken : (08000001) Name : value flags: [none] (00000000) ... Property #1 (17000001) ------------------------------------------------------Prop.Name : PetName (17000001) Flags : [none] (00000000) CallCnvntn: [PROPERTY] hasThis ReturnType: String No arguments. DefltValue: Setter : (06000002) set_PetName Getter : (06000001) get_PetName 0 Others ... First, note that the Car class metadata marks the type’s base class (System.Object) and includes various flags that describe how this type was constructed (e.g., [Public], [Abstract], and whatnot). Methods (such as our Car’s constructor) are described in regard to their parameters, return value, and name. Note how an automatic property results in a compiler-generated private backing field (which was named k__BackingField) and two compiler-generated methods (in the case of a read/write property) named, in this example, get_PetName() and set_PetName(). Finally, the actual property itself is mapped to the internal get/set methods using the .NET metadata Getter/Se tter tokens. 558