From 885808fb66233caf3057f0baa6368f4763a8eade Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Aug 2021 00:21:28 -0400 Subject: move assembly resolver setup into Constants to centralize hardcoded logic --- src/SMAPI/Constants.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/SMAPI/Constants.cs') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 6cbdeb8e..7f633a46 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using Mono.Cecil; using StardewModdingAPI.Enums; using StardewModdingAPI.Framework; using StardewModdingAPI.Framework.ModLoading; @@ -229,6 +230,21 @@ namespace StardewModdingAPI } } + /// Configure the Mono.Cecil assembly resolver. + /// The assembly resolver. + internal static void ConfigureAssemblyResolver(AssemblyDefinitionResolver resolver) + { + // add search paths + resolver.AddSearchDirectory(Constants.ExecutionPath); + resolver.AddSearchDirectory(Constants.InternalFilesPath); + + // add SMAPI explicitly + // Normally this would be handled automatically by the search paths, but for some reason there's a specific + // 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)); + } + /// Get metadata for mapping assemblies to the current platform. /// The target game platform. /// The game framework running the game. -- cgit From 976c66537c9f4493ce859c574675bb8651b5323f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Aug 2021 00:24:20 -0400 Subject: fix edge case where Netcode references aren't rewritten correctly --- docs/release-notes.md | 1 + src/SMAPI/Constants.cs | 11 +++++++++++ .../Framework/ModLoading/AssemblyDefinitionResolver.cs | 16 +++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/Constants.cs') 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 + ); } /// Get metadata for mapping assemblies to the current platform. 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); + } + + /// Add known assemblies to the resolver. + /// The assembly to add. + /// The assembly names for which it should be returned. + public void Add(AssemblyDefinition assembly, params string[] names) + { + this.RegisterAssembly(assembly); + foreach (string name in names) + this.Lookup[name] = assembly; } /// Resolve an assembly reference. -- cgit From 31ac964a8b19623b0472931403a33d51db6fb271 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 25 Aug 2021 21:53:45 -0400 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 13 +++++++------ src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.ErrorHandler/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/SMAPI/Constants.cs') diff --git a/build/common.targets b/build/common.targets index 498ec7af..06e0a245 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,7 +1,7 @@ - 3.12.2 + 3.12.3 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 4f597758..07eb6c03 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,23 +1,24 @@ ← [README](README.md) # Release notes -## Upcoming release +## 3.12.3 +Released 25 August 2021 for Stardew Valley 1.5.4 or later. + * For players: * Added friendly error in 64-bit mode when a mod is 32-bit only. * Fixed console encoding issues on Linux/macOS. - * Fixed some installer errors now show info header. + * Fixed some installer errors not showing info header. * For mod authors: * Added `helper.Translation.GetInAllLocales` to get a translation in every available locale. * Fixed Visual Studio debugger crash when any mods are rewritten for compatibility (thanks to spacechase0!). * Fixed `helper.Data.WriteJsonFile` not deleting the file if the model is null, unlike the other `Write*` methods. * Fixed error-handling for `StackOverflowException` thrown on Linux/macOS. - * Internal changes to prepare for upcoming releases. + * Internal changes to prepare for Stardew Valley 1.5.5. * For the web API: - * Fixed update checks... - * not recommending prerelease mod versions if the player has a beta SMAPI version; - * recommending prerelease versions if the player has a working non-prerelease version. + * Fixed update checks not shown for prerelease mod versions when you have a SMAPI beta. + * Fixed update checks shown for prerelease mod versions if you have a working non-prerelease version. ## 3.12.2 Released 05 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 6b49cd5f..e04d3497 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.2", + "Version": "3.12.3", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.12.2" + "MinimumApiVersion": "3.12.3" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index 7759d1d5..54758a36 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.2", + "Version": "3.12.3", "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.2" + "MinimumApiVersion": "3.12.3" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 1e5b8b97..f23f0958 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.2", + "Version": "3.12.3", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.12.2" + "MinimumApiVersion": "3.12.3" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index de6b63d6..cce267ba 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -62,7 +62,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.12.2"; + internal static string RawApiVersion = "3.12.3"; } /// Contains SMAPI's constants and assumptions. -- cgit