diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Constants.cs | 11 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs | 16 |
2 files changed, 22 insertions, 5 deletions
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> |