summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-13 18:20:09 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-13 18:20:09 -0400
commit63edebaef1019ce103f5a86d55e1d1c4eb8d371c (patch)
treea61b1ebd08324477b049699b63f405a5025555d6 /src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
parent66d2b5746ab063b89ca42525a78e217e71d00858 (diff)
downloadSMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.tar.gz
SMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.tar.bz2
SMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.zip
decouple mod metadata resolution from main SMAPI logic (#285)
This makes the logic more self-contained for eventual unit testing, and makes failed mods available during dependency resolution so we can make errors more relevant.
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
index 1ac167dc..72c4692b 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs
@@ -20,6 +20,12 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
public ModCompatibility Compatibility { get; }
+ /// <summary>The metadata resolution status.</summary>
+ public ModMetadataStatus Status { get; set; }
+
+ /// <summary>The reason the metadata is invalid, if any.</summary>
+ public string Error { get; set; }
+
/*********
** Public methods
@@ -30,11 +36,39 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="manifest">The mod manifest.</param>
/// <param name="compatibility">Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param>
public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility)
+ : this(displayName, directoryPath, manifest, compatibility, ModMetadataStatus.Found, null)
+ {
+ this.DisplayName = displayName;
+ this.DirectoryPath = directoryPath;
+ this.Manifest = manifest;
+ this.Compatibility = compatibility;
+ }
+
+ /// <summary>Construct an instance.</summary>
+ /// <param name="displayName">The mod's display name.</param>
+ /// <param name="directoryPath">The mod's full directory path.</param>
+ /// <param name="manifest">The mod manifest.</param>
+ /// <param name="compatibility">Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param>
+ /// <param name="status">The metadata resolution status.</param>
+ /// <param name="error">The reason the metadata is invalid, if any.</param>
+ public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility, ModMetadataStatus status, string error)
{
this.DisplayName = displayName;
this.DirectoryPath = directoryPath;
this.Manifest = manifest;
this.Compatibility = compatibility;
+ this.Status = status;
+ this.Error = error;
}
}
+
+ /// <summary>Indicates the status of a mod's metadata resolution.</summary>
+ internal enum ModMetadataStatus
+ {
+ /// <summary>The mod has been found, but hasn't been processed yet.</summary>
+ Found,
+
+ /// <summary>The mod cannot be loaded.</summary>
+ Failed
+ }
}