summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-08 00:24:20 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-08 00:24:20 -0400
commit976c66537c9f4493ce859c574675bb8651b5323f (patch)
tree1e16747a1f78e10baf68171140d9bb06f20aeb72
parent885808fb66233caf3057f0baa6368f4763a8eade (diff)
downloadSMAPI-976c66537c9f4493ce859c574675bb8651b5323f.tar.gz
SMAPI-976c66537c9f4493ce859c574675bb8651b5323f.tar.bz2
SMAPI-976c66537c9f4493ce859c574675bb8651b5323f.zip
fix edge case where Netcode references aren't rewritten correctly
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Constants.cs11
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs16
3 files changed, 23 insertions, 5 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 8c98af5d..9e42a847 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -4,6 +4,7 @@
## Upcoming release
* For mod authors:
* Fixed rare `NullReferenceException` in SMAPI's error-handling.
+ * Internal changes to prepare for upcoming releases.
## 3.12.2
Released 05 August 2021 for Stardew Valley 1.5.4 or later.
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 7f633a46..de6b63d6 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -243,6 +243,17 @@ namespace StardewModdingAPI
// case involving unofficial 64-bit Stardew Valley when launched through Steam (for some players only)
// where Mono.Cecil can't resolve references to SMAPI.
resolver.Add(AssemblyDefinition.ReadAssembly(typeof(SGame).Assembly.Location));
+
+ // make sure game assembly names can be resolved
+ // The game assembly can have one of three names depending how the mod was compiled:
+ // - '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"
+#if !SMAPI_FOR_WINDOWS
+ , "Netcode"
+#endif
+ );
}
/// <summary>Get metadata for mapping assemblies to the current platform.</summary>
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs b/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
index aefb0126..b3415609 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs
@@ -21,11 +21,17 @@ namespace StardewModdingAPI.Framework.ModLoading
public void Add(params AssemblyDefinition[] assemblies)
{
foreach (AssemblyDefinition assembly in assemblies)
- {
- this.RegisterAssembly(assembly);
- this.Lookup[assembly.Name.Name] = assembly;
- this.Lookup[assembly.Name.FullName] = assembly;
- }
+ this.Add(assembly, assembly.Name.Name, assembly.Name.FullName);
+ }
+
+ /// <summary>Add known assemblies to the resolver.</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)
+ {
+ this.RegisterAssembly(assembly);
+ foreach (string name in names)
+ this.Lookup[name] = assembly;
}
/// <summary>Resolve an assembly reference.</summary>