Programmatically compare the IL of two methods

I have a compiled assembly. I want to programmatically compare the implementation of a method of one of the methods in this assembly with what I expect.

Is there any way to compare their IL? Even if I can get a representation of the byte array of any set of commands, I will be in a good place.

Help evaluate.

+4
source share
5 answers

You can try using Reflection and compare IL using byte arrays.

Take a look at this method: http://msdn.microsoft.com/en-us/library/system.reflection.methodbody.getilasbytearray.aspx

+4
source

Using Mono.Cecil could be a good place to start. Cecil is the library used to read and modify CLR assemblies, and will do all the parsing of the files for you before capturing the CIL bytecode.

Another potential library you could use is Boogie

+4
source

You can reset assemblies using ildasm and distinguish between two versions:

ildasm /ALL /TEXT assembly1.dll > dump1.txt ildasm /ALL /TEXT assembly2.dll > dump2.txt fc dump1.txt dump2.txt 
+3
source

you can use ildasm.exe from the visual studio command line and do something like dll name ildasm.exe

0
source

You can use ildasm or reflector to extract IL from assembly

0
source

All Articles