I'm trying to figure out how MSIL is able to represent a call to a static function by only storing an integer.
For example, if you add a call to Interlocked.Increment(ref someVariable), your IL will contain the following:
0x28 | 0x12, 0x0, 0x0, 0xA
The pipe operator is my addition, essentially 0x28 is the call instruction and 012, 0x0, 0x0, 0xA is the "Interlocked.Increment" method.
Who decided that value? When you disassemble using ildasm, it pretty prints the name, but is there a table it looks up?
Where is this table defined?
According to ECMA-335, 0x0A000012 is a metadata token. Metadata token is basically a number that uniquely identifies a type, method, field etc. in the local module. 0x0A represents the MemberRef table in the module, and 0x12 is the index of the method in the table.
The table contains the the name and signature of the method (like its parameters and return type).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With