Search code examples
c#reflectionintermediate-language

Programmatically compare IL of two methods


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

Is there a way I can compare their ILs? Even if I can get a byte array representation of any instruction set, I'll be in a good place.

Help appreciated.


Solution

  • You could try using Reflection and compare the IL using byte arrays.

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