It most certainly is possible, but it'll be not too easy to code. Basically what you need to do is find all references to Lightning1 or its members in the assembly you're processing, and replace them with the appropriate reference to Lightning2, or its members. Go through all types in the assembly, and check their base type, and the generic arguments of the base type. Then go through all the methods in the type (including the property get_* and set_* methods - maybe even the event add_* and remove_* methods), fix their parameter and local variable types, then iterate through the instructions to find all references to Lightning1 or its member.
I believe the easiest way to achieve this would be to check the Operand of each instruction, and see if it's a TypeReference. If it is, check if it is Lightning1, and also check its generic arguments. If it's not a TypeReference, see if it's a MemberReference whose DeclaringType is Lightning1, or has Lightning1 as a generic argument. If Lightning1 is an attribute type, make sure to also check the CustomAttributes of all eligible members. I think that'll cover everything. I'm afraid I don't know any easier way to achieve this. Good luck! 2011/5/26 Paul Buonopane <[email protected]> > Is it possible to inject a type in another's place? For example, if I have > Lighting1 and Lighting2, the two being almost identical, could I inject > Lighting2 in place of Lighting1? If so, what would it entail? -- > -- > mono-cecil -- -- mono-cecil
