summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-05-09 12:13:39 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-05-09 12:13:39 -0400
commit7c76c5cad2c6edac75d6387dbaa5999295be46d8 (patch)
tree4236fed4088eacb4eee7f70634b2156a53951f6f /src/SMAPI/Framework
parent4b391d631ccde301969ae0c04f407a01ba4055b1 (diff)
downloadSMAPI-7c76c5cad2c6edac75d6387dbaa5999295be46d8.tar.gz
SMAPI-7c76c5cad2c6edac75d6387dbaa5999295be46d8.tar.bz2
SMAPI-7c76c5cad2c6edac75d6387dbaa5999295be46d8.zip
add validation for the manifest 'Dependencies' field
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index 3bf2b0a1..2f506571 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -188,6 +188,28 @@ namespace StardewModdingAPI.Framework.ModLoading
// validate ID format
if (!PathUtilities.IsSlug(mod.Manifest.UniqueID))
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, "its manifest specifies an invalid ID (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
+
+ // validate dependencies
+ foreach (var dependency in mod.Manifest.Dependencies)
+ {
+ // null dependency
+ if (dependency == null)
+ {
+ mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a null entry under {nameof(IManifest.Dependencies)}.");
+ continue;
+ }
+
+ // missing ID
+ if (string.IsNullOrWhiteSpace(dependency.UniqueID))
+ {
+ mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a {nameof(IManifest.Dependencies)} entry with no {nameof(IManifestDependency.UniqueID)} field.");
+ continue;
+ }
+
+ // invalid ID
+ if (!PathUtilities.IsSlug(dependency.UniqueID))
+ mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a {nameof(IManifest.Dependencies)} entry with an invalid {nameof(IManifestDependency.UniqueID)} field (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
+ }
}
// validate IDs are unique