Thank you very much, that worked! Also, you're right about the generic arguments. Forgot those. :(
Oh, and a bonus question. I have a problem with the callvirt instruction: it is late-bound. The problem is that I need the method that is actually called here. Is there a simple way of doing that? Right now what I have in mind is maintaining an evaluation stack for each method I process, pushing/popping values, as if the interpreter would do that, and when I come across a callvirt instruction, I just look at the type on the top of evaluation stack (skipping the parameters), and then I have the override method. However, this is going to be quite tough, considering that there are quite many instructions manipulating the evaluation stack (no wonder it's a stack-based language)... Any ideas? Thanks again! 2010/6/30 Jb Evain <[email protected]> > On Wed, Jun 30, 2010 at 8:18 PM, Gábor Kozár <[email protected]> wrote: > > Please have a look at it and tell me if I'm doing something wrong! > > You're not properly cloning the method attributes. Adding: > > newMethodDef.ImplAttributes = methodDef.ImplAttributes; > > Make it work. > > As a side note, how you clone interfaces look a bit dangerous: > > newTypeDef.Interfaces.Add (interfaceTypeRef.Resolve ().Clone ()); > > It means that you take a type, for instance IEnumerable<string>, that > you resolve to a type definition, that will give you IEnumerable<T> > defined in mscorlib, then you create a new object that looks like it > (but clone doesn't deal with generic parameters, so you'll have just > IEnumerable), and you add it to a type without adding it to a module. > Looks dangerous all right :) > > -- > Jb Evain <[email protected]> > > -- > -- > mono-cecil > -- -- mono-cecil
