public void Cloned_Type_Passes_PeVerify()
        {
            var fn = "Copycat.dll";

            try
            {
                if (File.Exists(fn))
                {
                    File.Delete(fn);
                }

                var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(IndependentClass).Assembly.Location);

                var destAssembly =
                    AssemblyDefinition.CreateAssembly(new AssemblyNameDefinition("Copycat", new Version(1, 1, 1, 1)),
                                                      "Copycat",
                                                      ModuleKind.Dll);
                var destinationModule = destAssembly.MainModule;

                var tdc = new TypeDefinitionCloner(destinationModule);
                tdc.Clone(sourceAssembly.MainModule.GetType("Pomona.UnitTests.CodeGen.IndependentClass"));
                //tdc.Clone(sourceAssembly.MainModule.GetType("Pomona.UnitTests.CodeGen.StringEnumExample"));
                destAssembly.Write(fn);

                PeVerifyHelper.Verify(fn);
            }
            finally
            {
                if (File.Exists(fn))
                {
                    File.Delete(fn);
                }
            }
        }
Esempio n. 2
0
 private static void PeVerify(string dllPath)
 {
     PeVerifyHelper.Verify(dllPath);
 }