summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/common.targets2
-rw-r--r--docs/release-notes.md6
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/manifest.json4
-rw-r--r--src/SMAPI.Mods.ErrorHandler/manifest.json4
-rw-r--r--src/SMAPI.Mods.SaveBackup/manifest.json4
-rw-r--r--src/SMAPI/Constants.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs16
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs27
8 files changed, 46 insertions, 21 deletions
diff --git a/build/common.targets b/build/common.targets
index 06e0a245..ca02ba30 100644
--- a/build/common.targets
+++ b/build/common.targets
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
- <Version>3.12.3</Version>
+ <Version>3.12.4</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 07eb6c03..3c9c0895 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -1,6 +1,12 @@
← [README](README.md)
# Release notes
+## 3.12.4
+Released 25 August 2021 for Stardew Valley 1.5.4 or later.
+
+* For players:
+ * Fixed error loading some mods in SMAPI 3.12.3.
+
## 3.12.3
Released 25 August 2021 for Stardew Valley 1.5.4 or later.
diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json
index e04d3497..e89dd582 100644
--- a/src/SMAPI.Mods.ConsoleCommands/manifest.json
+++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
- "Version": "3.12.3",
+ "Version": "3.12.4",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
- "MinimumApiVersion": "3.12.3"
+ "MinimumApiVersion": "3.12.4"
}
diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json
index 54758a36..ba51ed68 100644
--- a/src/SMAPI.Mods.ErrorHandler/manifest.json
+++ b/src/SMAPI.Mods.ErrorHandler/manifest.json
@@ -1,9 +1,9 @@
{
"Name": "Error Handler",
"Author": "SMAPI",
- "Version": "3.12.3",
+ "Version": "3.12.4",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll",
- "MinimumApiVersion": "3.12.3"
+ "MinimumApiVersion": "3.12.4"
}
diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json
index f23f0958..a4d7aeac 100644
--- a/src/SMAPI.Mods.SaveBackup/manifest.json
+++ b/src/SMAPI.Mods.SaveBackup/manifest.json
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
- "Version": "3.12.3",
+ "Version": "3.12.4",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
- "MinimumApiVersion": "3.12.3"
+ "MinimumApiVersion": "3.12.4"
}
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index cce267ba..8086ffa9 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -62,7 +62,7 @@ namespace StardewModdingAPI
internal static int? LogScreenId { get; set; }
/// <summary>SMAPI's current raw semantic version.</summary>
- internal static string RawApiVersion = "3.12.3";
+ internal static string RawApiVersion = "3.12.4";
}
/// <summary>Contains SMAPI's constants and assumptions.</summary>
@@ -249,7 +249,7 @@ namespace StardewModdingAPI
// - 'StardewValley': assembly name on Linux/macOS;
// - 'Stardew Valley': assembly name on Windows;
// - 'Netcode': an assembly that's separate on Windows only.
- resolver.Add(AssemblyDefinition.ReadAssembly(typeof(Game1).Assembly.Location), "StardewValley", "Stardew Valley"
+ resolver.AddWithExplicitNames(AssemblyDefinition.ReadAssembly(typeof(Game1).Assembly.Location), "StardewValley", "Stardew Valley"
#if !SMAPI_FOR_WINDOWS
, "Netcode"
#endif
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs b/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
index b3415609..8e2f5ef3 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
@@ -21,13 +21,13 @@ namespace StardewModdingAPI.Framework.ModLoading
public void Add(params AssemblyDefinition[] assemblies)
{
foreach (AssemblyDefinition assembly in assemblies)
- this.Add(assembly, assembly.Name.Name, assembly.Name.FullName);
+ this.AddWithExplicitNames(assembly, assembly.Name.Name, assembly.Name.FullName);
}
- /// <summary>Add known assemblies to the resolver.</summary>
+ /// <summary>Add a known assembly to the resolver with the given names. This overrides the assembly names that would normally be assigned.</summary>
/// <param name="assembly">The assembly to add.</param>
/// <param name="names">The assembly names for which it should be returned.</param>
- public void Add(AssemblyDefinition assembly, params string[] names)
+ public void AddWithExplicitNames(AssemblyDefinition assembly, params string[] names)
{
this.RegisterAssembly(assembly);
foreach (string name in names)
@@ -36,12 +36,18 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>Resolve an assembly reference.</summary>
/// <param name="name">The assembly name.</param>
- public override AssemblyDefinition Resolve(AssemblyNameReference name) => this.ResolveName(name.Name) ?? base.Resolve(name);
+ public override AssemblyDefinition Resolve(AssemblyNameReference name)
+ {
+ return this.ResolveName(name.Name) ?? base.Resolve(name);
+ }
/// <summary>Resolve an assembly reference.</summary>
/// <param name="name">The assembly name.</param>
/// <param name="parameters">The assembly reader parameters.</param>
- public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) => this.ResolveName(name.Name) ?? base.Resolve(name, parameters);
+ public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
+ {
+ return this.ResolveName(name.Name) ?? base.Resolve(name, parameters);
+ }
/*********
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
index e1ad9d37..3e35c9dd 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -233,15 +233,28 @@ namespace StardewModdingAPI.Framework.ModLoading
if (!file.Exists)
yield break; // not a local assembly
- // read assembly and symbols
- byte[] assemblyBytes = File.ReadAllBytes(file.FullName);
- Stream readStream = this.TrackForDisposal(new MemoryStream(assemblyBytes));
+ // read assembly
+ AssemblyDefinition assembly;
{
- 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()));
+ byte[] assemblyBytes = File.ReadAllBytes(file.FullName);
+ Stream readStream = this.TrackForDisposal(new MemoryStream(assemblyBytes));
+
+ try
+ {
+ // read assembly with symbols
+ 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()));
+ assembly = this.TrackForDisposal(AssemblyDefinition.ReadAssembly(readStream, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = assemblyResolver, InMemory = true, ReadSymbols = true, SymbolReaderProvider = this.SymbolReaderProvider }));
+ }
+ catch (SymbolsNotMatchingException ex)
+ {
+ // read assembly without symbols
+ this.Monitor.Log($" Failed loading PDB for '{file.Name}'. Technical details:\n{ex}");
+ readStream.Position = 0;
+ assembly = this.TrackForDisposal(AssemblyDefinition.ReadAssembly(readStream, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = assemblyResolver, InMemory = true }));
+ }
}
- AssemblyDefinition assembly = this.TrackForDisposal(AssemblyDefinition.ReadAssembly(readStream, new ReaderParameters(ReadingMode.Immediate) { AssemblyResolver = assemblyResolver, InMemory = true, ReadSymbols = true, SymbolReaderProvider = this.SymbolReaderProvider }));
// skip if already visited
if (visitedAssemblyNames.Contains(assembly.Name.Name))