.net - Where to go to view System.Collections.Generic IL code in ildasm? -


my curiosity piqued question, went in search of implementation of list.clear(). when ran ildasm on system.collections.dll so:

cd c:\program files (x86)\reference assemblies\microsoft\framework\.netcore\v4.5 "c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\netfx 4.5.1 tools\ildasm.exe" system.collections.dll 

and looked @ system.collections.generic.list`1::clear : void(), found:

.method public hidebysig newslot virtual final           instance void  clear() cil managed {   // code size       1 (0x1)   .maxstack  8   il_0000:  ret } // end of method list`1::clear 

that's not i'm looking for.

i'm aware .net dll's level of indirection different versions of framework can directed to. if that's case here, how figure out actual code is? or if there else going on, tips on how go using ildasm kind of task appreciated. i'm more capable @ using ildasm looking @ own stuff, not experienced @ using examine framework code.

update

using hans' pointer in right direction ended doing following:

cd c:\windows\microsoft.net\assembly\gac_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089 "c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\netfx 4.5.1 tools\ildasm.exe" mscorlib.dll 

this lead me following clear() method on system.collections.generic.list`1::clear : void():

.method public hidebysig newslot virtual final          instance void  clear() cil managed {   .custom instance void __dynamicallyinvokableattribute::.ctor() = ( 01 00 00 00 )    // code size       49 (0x31)   .maxstack  8   il_0000:  ldarg.0   il_0001:  ldfld      int32 class system.collections.generic.list`1<!t>::_size   il_0006:  ldc.i4.0   il_0007:  ble.s      il_0022   il_0009:  ldarg.0   il_000a:  ldfld      !0[] class system.collections.generic.list`1<!t>::_items   il_000f:  ldc.i4.0   il_0010:  ldarg.0   il_0011:  ldfld      int32 class system.collections.generic.list`1<!t>::_size   il_0016:  call       void system.array::clear(class system.array,                                                 int32,                                                 int32)   il_001b:  ldarg.0   il_001c:  ldc.i4.0   il_001d:  stfld      int32 class system.collections.generic.list`1<!t>::_size   il_0022:  ldarg.0   il_0023:  dup   il_0024:  ldfld      int32 class system.collections.generic.list`1<!t>::_version   il_0029:  ldc.i4.1   il_002a:  add   il_002b:  stfld      int32 class system.collections.generic.list`1<!t>::_version   il_0030:  ret } // end of method list`1::clear 

so led me @ system.array::clear(), gave me:

.method public hidebysig static void  clear(class system.array 'array',                                             int32 index,                                             int32 length) cil managed internalcall {   .custom instance void system.security.securitysafecriticalattribute::.ctor() = ( 01 00 00 00 )    .custom instance void system.runtime.constrainedexecution.reliabilitycontractattribute::.ctor(valuetype system.runtime.constrainedexecution.consistency,                                                                                                 valuetype system.runtime.constrainedexecution.cer) = ( 01 00 03 00 00 00 02 00 00 00 00 00 )    .custom instance void __dynamicallyinvokableattribute::.ctor() = ( 01 00 00 00 )  } // end of method array::clear 

which bit of dead-end, @ least know go kind of info.

the reference assemblies in .net 4+ special, contain metadata , il bodies stripped. pretty important allow them used target platforms different windows desktop , support pcl. actual code in them not matter @ all, compiler uses metadata.

also keep in mind mismatch between reference assemblies , runtime assemblies, many of reference assemblies contain [typeforwardedto] target specific runtime assembly platform provides.

if want peek @ code you'll need @ actual runtime assemblies. easy desktop, can navigate c:\windows\microsoft.net\assembly directly. used old machine copy .net 4.0 versions. silverlight easy well, navigate install directory. can phone ones emulator opening .vhd file. works windowsrt, never tried it. forget xbox.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -