diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-25 20:02:51 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-25 20:02:51 -0400 |
commit | 687a396e9c7581ebc2b35e58fc9b44d20d93a5d3 (patch) | |
tree | b1136efc6b4a8674c9f7adb2a44eb691668fae9d /src/SMAPI | |
parent | 0b29eb3bc37553aa2e9776e17727ba07018606ea (diff) | |
download | SMAPI-687a396e9c7581ebc2b35e58fc9b44d20d93a5d3.tar.gz SMAPI-687a396e9c7581ebc2b35e58fc9b44d20d93a5d3.tar.bz2 SMAPI-687a396e9c7581ebc2b35e58fc9b44d20d93a5d3.zip |
fix error when reading a duplicate assembly
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 5180f072..e1ad9d37 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -239,7 +239,7 @@ namespace StardewModdingAPI.Framework.ModLoading { FileInfo symbolsFile = new FileInfo(Path.Combine(Path.GetDirectoryName(file.FullName)!, Path.GetFileNameWithoutExtension(file.FullName)) + ".pdb"); if (symbolsFile.Exists) - this.SymbolReaderProvider.TryAddSymbolData(file.Name, this.TrackForDisposal(symbolsFile.OpenRead())); + this.SymbolReaderProvider.TryAddSymbolData(file.Name, () => this.TrackForDisposal(symbolsFile.OpenRead())); } AssemblyDefinition assembly = this.TrackForDisposal(AssemblyDefinition.ReadAssembly(readStream, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = assemblyResolver, InMemory = true, ReadSymbols = true, SymbolReaderProvider = this.SymbolReaderProvider })); diff --git a/src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs b/src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs index 02a70f1c..1b160690 100644 --- a/src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs +++ b/src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs @@ -24,10 +24,11 @@ namespace StardewModdingAPI.Framework.ModLoading.Symbols *********/ /// <summary>Add the symbol file for a given assembly name, if it's not already registered.</summary> /// <param name="fileName">The assembly file name.</param> - /// <param name="symbolStream">The raw file stream for the symbols.</param> - public void AddSymbolData(string fileName, Stream symbolStream) + /// <param name="getSymbolStream">Get the raw file stream for the symbols.</param> + public void TryAddSymbolData(string fileName, Func<Stream> getSymbolStream) { - this.SymbolsByAssemblyPath.Add(fileName, symbolStream); + if (!this.SymbolsByAssemblyPath.ContainsKey(fileName)) + this.SymbolsByAssemblyPath.Add(fileName, getSymbolStream()); } /// <summary>Get a symbol reader for a given module and assembly name.</summary> |