fix 'unknown mod' deprecation warnings when they occur in the Mod constructor

This commit is contained in:
Jesse Plamondon-Willard 2018-12-31 14:40:42 -05:00
parent c4a76df4b0
commit 0f926ca1c9
No known key found for this signature in database
GPG Key ID: 7D7C8097B62033CE
3 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,7 @@
* Added mod page link to 'missing dependency' errors for the most common dependencies.
* Restrict to Stardew Valley 1.3.33 or earlier (to avoid confusion when SDV 1.3.35 is released).
* Fixed 'unknown mod' deprecation warnings showing a stack trace when developers mode not enabled.
* Fixed 'unknown mod' deprecation warnings when they occur in the Mod constructor.
* For modders:
* Fixed `Constants.SaveFolderName` and `CurrentSavePath` not available during early load stages when using `Specialised.LoadStageChanged` event.

View File

@ -33,8 +33,14 @@ namespace StardewModdingAPI.Framework
public void Add(IModMetadata metadata)
{
this.Mods.Add(metadata);
if (!metadata.IsContentPack)
this.ModNamesByAssembly[metadata.Mod.GetType().Assembly.FullName] = metadata;
}
/// <summary>Track a mod's assembly for use via <see cref="GetFrom"/>.</summary>
/// <param name="metadata">The mod metadata.</param>
/// <param name="modAssembly">The mod assembly.</param>
public void TrackAssemblies(IModMetadata metadata, Assembly modAssembly)
{
this.ModNamesByAssembly[modAssembly.FullName] = metadata;
}
/// <summary>Get metadata for all loaded mods.</summary>

View File

@ -977,6 +977,7 @@ namespace StardewModdingAPI.Framework
try
{
modAssembly = assemblyLoader.Load(mod, assemblyPath, assumeCompatible: mod.DataRecord?.Status == ModStatus.AssumeCompatible);
this.ModRegistry.TrackAssemblies(mod, modAssembly);
}
catch (IncompatibleInstructionException) // details already in trace logs
{