1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly genericmethods
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module genericmethods.exe
// MVID: {62CAFB9A-4CDB-4A62-8A4F-DC7648609070}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x01790000
// =============== CLASS MEMBERS DECLARATION ===================
.class interface private abstract auto ansi IFoo
{
.method public hidebysig newslot virtual
instance class [mscorlib]System.Type
Foo<T>() cil managed
{
// Code size 37 (0x25)
.maxstack 2
.locals init (class [mscorlib]System.Type V_0)
IL_0000: nop
IL_0001: ldstr "At IFoo<T>::Foo<T>: TypeOf(T) = {0}"
IL_0006: ldtoken !!T
IL_000b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0010: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0015: nop
IL_0016: ldtoken !!T
IL_001b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0020: stloc.0
IL_0021: br.s IL_0023
IL_0023: ldloc.0
IL_0024: ret
} // end of method IFoo::Foo
} // end of class IFoo
.class interface private abstract auto ansi IBar`1<T>
{
.method public hidebysig newslot virtual
instance class [mscorlib]System.Type
Bar1<P>() cil managed
{
// Code size 37 (0x25)
.maxstack 2
.locals init (class [mscorlib]System.Type V_0)
IL_0000: nop
IL_0001: ldstr "At IBar<T>::Foo<P>: TypeOf(P) = {0}"
IL_0006: ldtoken !!P
IL_000b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0010: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0015: nop
IL_0016: ldtoken !!P
IL_001b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0020: stloc.0
IL_0021: br.s IL_0023
IL_0023: ldloc.0
IL_0024: ret
} // end of method IBar`1::Bar1
.method public hidebysig newslot virtual
instance class [mscorlib]System.Type
Bar2<K>() cil managed
{
// Code size 37 (0x25)
.maxstack 2
.locals init (class [mscorlib]System.Type V_0)
IL_0000: nop
IL_0001: ldstr "At IBar<T>::Bar2<K>: TypeOf(K) = {0}"
IL_0006: ldtoken !!K
IL_000b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0010: call void [mscorlib]System.Console::WriteLine(string,
object)
IL_0015: nop
IL_0016: ldtoken !!K
IL_001b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0020: stloc.0
IL_0021: br.s IL_0023
IL_0023: ldloc.0
IL_0024: ret
} // end of method IBar`1::Bar2
.method public hidebysig newslot virtual
instance void Bar3<P,K>([out] class [mscorlib]System.Type& t,
[out] class [mscorlib]System.Type& u) cil managed
{
// Code size 57 (0x39)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "At IBar<T>::Bar3<P, K>: TypeOf(P) = {0}, TypeOf(K)"
+ " = {1}"
IL_0006: ldtoken !!P
IL_000b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0010: ldtoken !!K
IL_0015: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_001a: call void [mscorlib]System.Console::WriteLine(string,
object,
object)
IL_001f: nop
IL_0020: ldarg.1
IL_0021: ldtoken !!P
IL_0026: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_002b: stind.ref
IL_002c: ldarg.2
IL_002d: ldtoken !!K
IL_0032: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0037: stind.ref
IL_0038: ret
} // end of method IBar`1::Bar3
} // end of class IBar`1
.class private auto ansi beforefieldinit FooBar`1<V>
extends [mscorlib]System.Object
implements IFoo,
class IBar`1<!V>
{
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method FooBar`1::.ctor
} // end of class FooBar`1
.class private auto ansi beforefieldinit Program
extends [mscorlib]System.Object
{
.method private hidebysig static int32
Main(string[] args) cil managed
{
.entrypoint
// Code size 223 (0xdf)
.maxstack 3
.locals init (class FooBar`1<object> V_0,
class IFoo V_1,
class IBar`1<object> V_2,
class [mscorlib]System.Type V_3,
class [mscorlib]System.Type V_4,
int32 V_5)
IL_0000: nop
IL_0001: newobj instance void class FooBar`1<object>::.ctor()
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: stloc.1
IL_0009: ldloc.0
IL_000a: stloc.2
IL_000b: ldstr "Calling IFoo.Foo<String> on FooBar<Object> - expec"
+ "ting IFoo::Foo<string>() returning typeof(string)"
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
IL_0015: nop
IL_0016: ldloc.1
IL_0017: callvirt instance class [mscorlib]System.Type IFoo::Foo<string>()
IL_001c: ldtoken [mscorlib]System.String
IL_0021: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0026: call bool [mscorlib]System.Type::op_Equality(class [mscorlib]System.Type,
class [mscorlib]System.Type)
IL_002b: ldstr "Calling IFoo.Foo<String> on FooBar<Object>"
IL_0030: call void Test::Assert(bool,
string)
IL_0035: nop
IL_0036: ldstr "Calling IBar.Bar1<String> on FooBar<object> - expe"
+ "cting bar.Bar1<string>() returning typeof(string)"
IL_003b: call void [mscorlib]System.Console::WriteLine(string)
IL_0040: nop
IL_0041: ldloc.2
IL_0042: callvirt instance class [mscorlib]System.Type class IBar`1<object>::Bar1<string>()
IL_0047: ldtoken [mscorlib]System.String
IL_004c: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0051: call bool [mscorlib]System.Type::op_Equality(class [mscorlib]System.Type,
class [mscorlib]System.Type)
IL_0056: ldstr "Calling IBar.Bar1<String> on FooBar<object>"
IL_005b: call void Test::Assert(bool,
string)
IL_0060: nop
IL_0061: ldstr "Calling IBar.Bar2<String[]> on FooBar<object> - ex"
+ "pecting bar.Bar2<string[]>() returning typeof(string[])"
IL_0066: call void [mscorlib]System.Console::WriteLine(string)
IL_006b: nop
IL_006c: ldloc.2
IL_006d: callvirt instance class [mscorlib]System.Type class IBar`1<object>::Bar2<string[]>()
IL_0072: ldtoken string[]
IL_0077: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_007c: call bool [mscorlib]System.Type::op_Equality(class [mscorlib]System.Type,
class [mscorlib]System.Type)
IL_0081: ldstr "Calling IBar.Bar2<String[]> on FooBar<object>"
IL_0086: call void Test::Assert(bool,
string)
IL_008b: nop
IL_008c: ldstr "Calling IBar.Bar3<String, String[]> - expecting ba"
+ "r.Bar3<string>() returning typeof(string), typeof(string[])"
IL_0091: call void [mscorlib]System.Console::WriteLine(string)
IL_0096: nop
IL_0097: ldloc.2
IL_0098: ldloca.s V_3
IL_009a: ldloca.s V_4
IL_009c: callvirt instance void class IBar`1<object>::Bar3<string,string[]>(class [mscorlib]System.Type&,
class [mscorlib]System.Type&)
IL_00a1: nop
IL_00a2: ldloc.3
IL_00a3: ldtoken [mscorlib]System.String
IL_00a8: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00ad: call bool [mscorlib]System.Type::op_Equality(class [mscorlib]System.Type,
class [mscorlib]System.Type)
IL_00b2: brfalse.s IL_00c7
IL_00b4: ldloc.s V_4
IL_00b6: ldtoken string[]
IL_00bb: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_00c0: call bool [mscorlib]System.Type::op_Equality(class [mscorlib]System.Type,
class [mscorlib]System.Type)
IL_00c5: br.s IL_00c8
IL_00c7: ldc.i4.0
IL_00c8: ldstr "Calling IBar.Bar3<String, String[]>"
IL_00cd: call void Test::Assert(bool,
string)
IL_00d2: nop
IL_00d3: call int32 Test::Ret()
IL_00d8: stloc.s V_5
IL_00da: br.s IL_00dc
IL_00dc: ldloc.s V_5
IL_00de: ret
} // end of method Program::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Program::.ctor
} // end of class Program
.class private auto ansi beforefieldinit Test
extends [mscorlib]System.Object
{
.field private static bool Pass
.method public hidebysig static int32 Ret() cil managed
{
// Code size 19 (0x13)
.maxstack 1
.locals init (int32 V_0)
IL_0000: nop
IL_0001: ldsfld bool Test::Pass
IL_0006: brtrue.s IL_000c
IL_0008: ldc.i4.s 101
IL_000a: br.s IL_000e
IL_000c: ldc.i4.s 100
IL_000e: stloc.0
IL_000f: br.s IL_0011
IL_0011: ldloc.0
IL_0012: ret
} // end of method Test::Ret
.method public hidebysig static void Assert(bool cond,
string msg) cil managed
{
// Code size 47 (0x2f)
.maxstack 2
.locals init (bool V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: brfalse.s IL_0015
IL_0006: nop
IL_0007: ldstr "PASS"
IL_000c: call void [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: nop
IL_0013: br.s IL_002e
IL_0015: nop
IL_0016: ldstr "FAIL: "
IL_001b: ldarg.1
IL_001c: call string [mscorlib]System.String::Concat(string,
string)
IL_0021: call void [mscorlib]System.Console::WriteLine(string)
IL_0026: nop
IL_0027: ldc.i4.0
IL_0028: stsfld bool Test::Pass
IL_002d: nop
IL_002e: ret
} // end of method Test::Assert
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method Test::.ctor
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldc.i4.1
IL_0001: stsfld bool Test::Pass
IL_0006: ret
} // end of method Test::.cctor
} // end of class Test
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file genericmethods.res
|