The ILDasm tool (MSIL Disassembler) is an indispensable tool for most developers. This tool allows the developer to parse any .NET Framework Assembly and generate a human-readable format. It ships with the .Net Framework SDK and it is well worth your time to learn how to use it. To present the information in as compact a form as possible, ILDasm encodes key information about a type or section of the assembly with about 13 different symbols. After you become familiar with these symbols, you will have a much easier time understanding the UI output of ILDasm. Table 5.1 shows a list of the symbols and their meanings along with a small code snippet from C# and IL to illustrate how the data that is represented by the symbol can appear in your code.
Icon | Description | C# | IL |
---|---|---|---|
More Info | |||
Namespace | namespace CLRUnleashed.IL | .namespace CLRUnleashed.IL | |
Class | class MathOperations | .class ... MathOperations | |
Interface | interface IBasicArithmetic | .class interface ... IBasicOperations | |
Struct | struct Complex {. . .} | .class ... Complex extends ValueType | |
Enum | enum OperationType {. . .} | .class ... OperationType extends Enum | |
Method | int Add(int a, int b) {. . .} | .method ... int32 Add(int32 a, int32 b) | |
Static Method | static void Main(string[] args) | .method ... static void Main(string[] args) | |
Field | int addCount; | .field ... int32 addCount | |
Static Field | static int constructionCount = 0; | .field ... static int32 constructionCount | |
Event | event OperationHandler Operation; | .event ... OperationHandler Operation | |
Property | int Count { get {...} } | .property int32 Count() | |
Manifest |
A simple sample program has been put together that really doesn't have functionality except to illustrate each of the symbols of ILDasm. Many of the details of these data types are explored in later chapters, but for now, just focus on the source to IL mapping. ILSampler is in the ILSampler subdirectory. Compile this sample and use ILDasm to look at the code that is generated.
Note
As a reminder, the MSIL Disassemblier (ILDasm) is shipped with the .NET Framework SDK and is in Program FilesMicrosoft Visual Studio .NETFrameworkSDKin as ILDasm.exe.
3.144.25.74