diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-05-21 21:59:45 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-05-21 21:59:45 -0400 |
commit | f8e0600672952fa211b118df27f359581ee4b1f1 (patch) | |
tree | b656b2f72ef66b02e43eb22fc3bb9e57110d88ae /src/SMAPI | |
parent | 1beee07a3548f4f7efe9d4044ec7a3eb78987f89 (diff) | |
download | SMAPI-f8e0600672952fa211b118df27f359581ee4b1f1.tar.gz SMAPI-f8e0600672952fa211b118df27f359581ee4b1f1.tar.bz2 SMAPI-f8e0600672952fa211b118df27f359581ee4b1f1.zip |
load .pdb file when mod is loaded from bytes (#711)
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 5218938f..eadb2997 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -127,10 +127,21 @@ namespace StardewModdingAPI.Framework.ModLoading { if (!oneAssembly) this.Monitor.Log($" Loading {assembly.File.Name} (rewritten)...", LogLevel.Trace); + + // load PDB file if present + byte[] symbols; + { + string symbolsPath = Path.Combine(Path.GetDirectoryName(assemblyPath), Path.GetFileNameWithoutExtension(assemblyPath)) + ".pdb"; + symbols = File.Exists(symbolsPath) + ? File.ReadAllBytes(symbolsPath) + : null; + } + + // load assembly using MemoryStream outStream = new MemoryStream(); assembly.Definition.Write(outStream); byte[] bytes = outStream.ToArray(); - lastAssembly = Assembly.Load(bytes); + lastAssembly = Assembly.Load(bytes, symbols); } else { |