pass SMAPI version into metadata validation to simplify unit tests (#285)

This commit is contained in:
Jesse Plamondon-Willard 2017-05-13 21:38:04 -04:00
parent 53547a8ca3
commit f03b300b3f
2 changed files with 5 additions and 4 deletions

View File

@ -75,7 +75,8 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <summary>Validate manifest metadata.</summary>
/// <param name="mods">The mod manifests to validate.</param>
public void ValidateManifests(IEnumerable<IModMetadata> mods)
/// <param name="apiVersion">The current SMAPI version.</param>
public void ValidateManifests(IEnumerable<IModMetadata> mods, ISemanticVersion apiVersion)
{
foreach (IModMetadata mod in mods)
{
@ -108,10 +109,10 @@ namespace StardewModdingAPI.Framework.ModLoading
{
if (!SemanticVersion.TryParse(mod.Manifest.MinimumApiVersion, out ISemanticVersion minVersion))
{
mod.SetStatus(ModMetadataStatus.Failed, $"it has an invalid minimum SMAPI version '{mod.Manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.ApiVersion}.");
mod.SetStatus(ModMetadataStatus.Failed, $"it has an invalid minimum SMAPI version '{mod.Manifest.MinimumApiVersion}'. This should be a semantic version number like {apiVersion}.");
continue;
}
if (minVersion.IsNewerThan(Constants.ApiVersion))
if (minVersion.IsNewerThan(apiVersion))
{
mod.SetStatus(ModMetadataStatus.Failed, $"it needs SMAPI {minVersion} or later. Please update SMAPI to the latest version to use this mod.");
continue;

View File

@ -318,7 +318,7 @@ namespace StardewModdingAPI
// load manifests
IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModCompatibility).ToArray();
resolver.ValidateManifests(mods);
resolver.ValidateManifests(mods, Constants.ApiVersion);
// check for deprecated metadata
IList<Action> deprecationWarnings = new List<Action>();