/// <summary> /// Patches the specified input PDB file. /// </summary> /// <param name="inputExeFile">The input PDB file.</param> /// <param name="outputPdbFile">The output PDB file.</param> /// <param name="sourcePathRewriter">The source path modifier.</param> /// <exception cref="System.ArgumentNullException">inputExeFile</exception> public static void Patch(string inputExeFile, string outputPdbFile, SourcePathRewriterDelegate sourcePathRewriter) { if (inputExeFile == null) throw new ArgumentNullException("inputExeFile"); if (outputPdbFile == null) throw new ArgumentNullException("outputPdbFile"); if (sourcePathRewriter == null) throw new ArgumentNullException("sourcePathRewriter"); // Copy PDB from input assembly to output assembly if any var inputPdbFile = Path.ChangeExtension(inputExeFile, "pdb"); if (!File.Exists(inputPdbFile)) { ShowMessage(string.Format("Warning file [{0}] does not exist", inputPdbFile), ConsoleColor.Yellow); return; } var symbolReaderProvider = new PdbReaderProvider(); var readerParameters = new ReaderParameters { SymbolReaderProvider = symbolReaderProvider, ReadSymbols = true }; // Read Assembly var assembly = AssemblyDefinition.ReadAssembly(inputExeFile, readerParameters); // Write back the assembly and pdb assembly.Write(inputExeFile, new WriterParameters {WriteSymbols = true, SourcePathRewriter = sourcePathRewriter}); }
/// <summary> /// Patches the specified input PDB file. /// </summary> /// <param name="inputExeFile">The input PDB file.</param> /// <param name="outputPdbFile">The output PDB file.</param> /// <param name="sourcePathRewriter">The source path modifier.</param> /// <exception cref="System.ArgumentNullException">inputExeFile</exception> public static void Patch(string inputExeFile, string outputPdbFile, SourcePathRewriterDelegate sourcePathRewriter) { if (inputExeFile == null) { throw new ArgumentNullException("inputExeFile"); } if (outputPdbFile == null) { throw new ArgumentNullException("outputPdbFile"); } if (sourcePathRewriter == null) { throw new ArgumentNullException("sourcePathRewriter"); } // Copy PDB from input assembly to output assembly if any var inputPdbFile = Path.ChangeExtension(inputExeFile, "pdb"); if (!File.Exists(inputPdbFile)) { ShowMessage(string.Format("Warning file [{0}] does not exist", inputPdbFile), ConsoleColor.Yellow); return; } var symbolReaderProvider = new PdbReaderProvider(); var readerParameters = new ReaderParameters { SymbolReaderProvider = symbolReaderProvider, ReadSymbols = true }; // Read Assembly var assembly = AssemblyDefinition.ReadAssembly(inputExeFile, readerParameters); // Write back the assembly and pdb assembly.Write(inputExeFile, new WriterParameters { WriteSymbols = true, SourcePathRewriter = sourcePathRewriter }); }