summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-02-03 20:12:42 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-02-03 20:12:42 -0500
commit5e68400c43000f07a29103cacccacde72b0cce2e (patch)
tree25094b6eb97282be948bbf611af8025fa119f529 /src/StardewModdingAPI/Framework
parent4fff06cce19fcc5f75da949f37cff4ca3ee46b44 (diff)
downloadSMAPI-5e68400c43000f07a29103cacccacde72b0cce2e.tar.gz
SMAPI-5e68400c43000f07a29103cacccacde72b0cce2e.tar.bz2
SMAPI-5e68400c43000f07a29103cacccacde72b0cce2e.zip
only read assembly from memory if it was rewritten (#229)
This fixes an issue where you can't debug into mod code because SMAPI isn't loading the actual DLL.
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/AssemblyLoader.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Framework/AssemblyLoader.cs b/src/StardewModdingAPI/Framework/AssemblyLoader.cs
index 8b2f29e1..123211b9 100644
--- a/src/StardewModdingAPI/Framework/AssemblyLoader.cs
+++ b/src/StardewModdingAPI/Framework/AssemblyLoader.cs
@@ -72,14 +72,19 @@ namespace StardewModdingAPI.Framework
Assembly lastAssembly = null;
foreach (AssemblyParseResult assembly in assemblies)
{
- this.Monitor.Log($"Loading {assembly.File.FullName}...", LogLevel.Trace);
- this.RewriteAssembly(assembly.Definition);
- using (MemoryStream outStream = new MemoryStream())
+ this.Monitor.Log($"Loading {assembly.File.Name}...", LogLevel.Trace);
+ bool changed = this.RewriteAssembly(assembly.Definition);
+ if (changed)
{
- assembly.Definition.Write(outStream);
- byte[] bytes = outStream.ToArray();
- lastAssembly = Assembly.Load(bytes);
+ using (MemoryStream outStream = new MemoryStream())
+ {
+ assembly.Definition.Write(outStream);
+ byte[] bytes = outStream.ToArray();
+ lastAssembly = Assembly.Load(bytes);
+ }
}
+ else
+ lastAssembly = Assembly.UnsafeLoadFrom(assembly.File.FullName);
}
// last assembly loaded is the root