The Module of the Instruction's Operand is incorrect #109

Closed
opened 2012-09-26 10:53:45 -05:00 by andrasfuchs · 2 comments
andrasfuchs commented 2012-09-26 10:53:45 -05:00 (Migrated from github.com)

When you load an assembly, get one of its methods and look for a method which has a Mono.Cecil.MethodReference operand, then the operand's DeclarintType.Module will be incorrectly the module where the method (and not the operand) is.

Example:

Assembly1.MainModule.Type1.Method1 has a Mono.Cecil.Cil.Instruction which is a Mono.Cecil.Cil.Code.Callvirt. It's operand is a Mono.Cecil.MethodReference. The method is located in Assembly2.MainModule.Type2. It's called Method2.

When we get to the call, the Operand's DeclaringType is correctly has the right full name "Namespace.Type2", and the Operand's .Name property is also correct (Method2).

The problem is, that the Operand's DeclarintType.Module does not return the right module (Assembly2.MainModule), but returns the method's module which we read the instructions from (Assembly1.MainModule).

I think it's similar to issue #79.

Drop me a line if you need code samples. Keep up the good work, Cecil rocks!

When you load an assembly, get one of its methods and look for a method which has a Mono.Cecil.MethodReference operand, then the operand's DeclarintType.Module will be incorrectly the module where the method (and not the operand) is. Example: Assembly1.MainModule.Type1.Method1 has a Mono.Cecil.Cil.Instruction which is a Mono.Cecil.Cil.Code.Callvirt. It's operand is a Mono.Cecil.MethodReference. The method is located in Assembly2.MainModule.Type2. It's called Method2. When we get to the call, the Operand's DeclaringType is correctly has the right full name "Namespace.Type2", and the Operand's .Name property is also correct (Method2). The problem is, that the Operand's DeclarintType.Module does not return the right module (Assembly2.MainModule), but returns the method's module which we read the instructions from (Assembly1.MainModule). I think it's similar to issue #79. Drop me a line if you need code samples. Keep up the good work, Cecil rocks!
jbevain commented 2012-09-26 10:56:01 -05:00 (Migrated from github.com)
No it's not :) http://stackoverflow.com/questions/6832503/mono-cecil-module-of-basetype-is-incorrect
andrasfuchs commented 2012-09-26 11:04:43 -05:00 (Migrated from github.com)

Wow, that was the quickest response I've ever got to a bugreport :) Thanks mate, it works with the Scope and AssemblyResolver!

Wow, that was the quickest response I've ever got to a bugreport :) Thanks mate, it works with the Scope and AssemblyResolver!
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#109
No description provided.