Adding new types to an assembly

Feb 23, 2011 at 8:52 PM


I am using a CodeAndContractMutator (through CCISharp). I want to add new types to my assembly. I successfully define the new types, wrap them in a namespace, obtain the UnitNamespaceRoot of my assembly and add the namespcae and containing types to the Members collection of the RootUnitNamespace object. The problem I have occurs in PeWriter. When the writer creates the indices for methods in the assembly, it uses "this.module.GetAllTypes()", but the AllTypes collection was never updated to include my new types.


I would like to know if there is an alternate way to accomplish what I am trying to do? This was working fine until recently, when I took a refresh of the CCISharp code from CodePlex.

Any help is greatly appreciated

Sebastien Clement

Feb 24, 2011 at 2:22 PM

I seem to have found the solution. Turns out I have to cast the IAssembly to a mutable assembly and manually add the new types to the AllTypes collection.