Free mag vol1 | Page 579

CHAPTER 14  BUILDING AND CONFIGURING CLASS LIBRARIES into memory, the underlying CIL is compiled (using the JIT compiler) into instructions that can be understood by the target platform. For example, back in ildasm.exe, if you double-click the TurboBoost() method of the SportsCar class, ildasm.exe will open a new window showing the CIL tokens that implement this method. .method public hidebysig virtual instance void TurboBoost() cil managed { // Code size 18 (0x12) .maxstack 8 IL_0000: nop IL_0001: ldstr "Ramming speed!" IL_0006: ldstr "Faster is better..." IL_000b: call valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string, string) IL_0010: pop IL_0011: ret } // end of method SportsCar::TurboBoost Again, while most .NET developers don’t need to be deeply concerned with the details of CIL on a daily basis, Chapter 18 provides more details on its syntax and semantics. Believe it or not, understanding the grammar of CIL can be helpful when you are building more complex applications that require advanced services, such as runtime construction of assemblies (again, see Chapter 18). Exploring the Type Metadata Before we build some applications that make use of our custom .NET library, if you press the Ctrl+M keystroke combination in ildasm.exe, you can see the metadata for each type within the CarLibrary.dll assembly (see Figure 14-7). Figure 14-7. Type metadata for the types within CarLibrary.dll 521