void AssertWriteToPeFile(PeVerifyResult expectedResult, IAssembly assembly, string pdbPath) { var validator = new MetadataValidator(this.host); List <Microsoft.Cci.ErrorEventArgs> errorEvents = new List <Microsoft.Cci.ErrorEventArgs>(); this.host.Errors += (object sender, Microsoft.Cci.ErrorEventArgs e) => errorEvents.Add(e); validator.Validate(assembly); Debug.Assert(errorEvents.Count == 0); using (var rewrittenFile = File.Create(assembly.Location)) { if (pdbPath != null) { using (var f = File.OpenRead(pdbPath)) { using (var pdbReader = new PdbReader(f, host)) { using (var pdbWriter = new PdbWriter(Path.GetFullPath(assembly.Location + ".pdb"), pdbReader)) { PeWriter.WritePeToStream(assembly, host, rewrittenFile, pdbReader, pdbReader, pdbWriter); } } } } else { using (var pdbWriter = new PdbWriter(Path.GetFullPath(assembly.Location + ".pdb"), null)) { PeWriter.WritePeToStream(assembly, host, rewrittenFile, null, null, pdbWriter); } } } Assert.True(File.Exists(assembly.Location)); PeVerify.Assert(expectedResult, PeVerify.VerifyAssembly(assembly.Location, true)); }
void AssertWriteToPeFile(PeVerifyResult expectedResult, IAssembly assembly, PdbReader pdbReader) { using (var rewrittenFile = File.Create(assembly.Location)) { using (var pdbWriter = new PdbWriter(Path.GetFullPath(assembly.Location + ".pdb"), pdbReader)) { PeWriter.WritePeToStream(assembly, host, rewrittenFile, pdbReader, pdbReader, pdbWriter); } } Assert.True(File.Exists(assembly.Location)); PeVerify.Assert(expectedResult, PeVerify.VerifyAssembly(assembly.Location, true)); }
void AssertWriteToPeFile(PeVerifyResult expectedResult, IAssembly assembly) { using (FileStream rewrittenFile = File.Create(assembly.Location)) { using (this.pdbReader) { PeWriter.WritePeToStream(assembly, this.host, rewrittenFile, this.pdbReader, this.pdbReader, this.pdbWriter); } } Assert.True(File.Exists(assembly.Location)); PeVerify.Assert(expectedResult, PeVerify.VerifyAssembly(assembly.Location)); }