Hello everyone!
I'm new to Mono Cecil and I'd like to create something similar to this RAIL (http://rail.dei.uc.pt/) snippet using the Mono.Cecil API: //Create the RAssemblyDef objects of the two assemblies RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly("Teste.exe"); RAssemblyDef rAssembly2 = RAssemblyDef.LoadAssembly("Teste2.dll"); //Get the type to copy from assembly Teste2.dll to //assembly Teste.exe RType typeToCopy = rAssembly2.RModuleDef.GetType("Bar"); //Copies the type Bar to Teste.exe assembly rAssembly.RModuleDef.CopyType(typeToCopy,typeToCopy.Name); //Creates the RType instances of the to types RType oldType = rAssembly.RModuleDef.GetType("Foo"); RType newType = rAssembly.RModuleDef.GetType("Bar"); //Creates the ReferenceReplacer visitor object ReferenceReplacer rr = new ReferenceReplacer(oldType,newType); //Apply the change to the assembly an its members rAssembly.Accept(rr); //Remove the previous used type Foo rAssembly.RModuleDef.RemoveType("Foo"); //Save the new assembly rAssembly.SaveAssembly("Teste.exe"); Thus, I'm wondering * How to copy a Type declaration from one module/assembly to another? * How to write some sort of visitor class that allows me to easily visit all Type references of my assembly so that I can change the external type these references point to (e.g. because I've moved that type from one assembly to the other)? Any idea or hint on where to start looking? Any example or wiki page that may shed some light on these topics? Thanks in advance, Chris -- View this message in context: http://www.nabble.com/Copying-and-replacing-types-or-their-references-tp18149401p18149401.html Sent from the Mono - Cecil mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
