rename mod compatibility records for broader use (#361)
This commit is contained in:
parent
a89dbce854
commit
9495cc0f49
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -30,7 +30,7 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
Directory.CreateDirectory(rootFolder);
|
Directory.CreateDirectory(rootFolder);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
|
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModDataRecord[0]).ToArray();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
Assert.AreEqual(0, mods.Length, 0, $"Expected to find zero manifests, found {mods.Length} instead.");
|
Assert.AreEqual(0, mods.Length, 0, $"Expected to find zero manifests, found {mods.Length} instead.");
|
||||||
|
@ -45,7 +45,7 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
Directory.CreateDirectory(modFolder);
|
Directory.CreateDirectory(modFolder);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
|
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModDataRecord[0]).ToArray();
|
||||||
IModMetadata mod = mods.FirstOrDefault();
|
IModMetadata mod = mods.FirstOrDefault();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
|
@ -84,13 +84,13 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
File.WriteAllText(filename, JsonConvert.SerializeObject(original));
|
File.WriteAllText(filename, JsonConvert.SerializeObject(original));
|
||||||
|
|
||||||
// act
|
// act
|
||||||
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModCompatibility[0]).ToArray();
|
IModMetadata[] mods = new ModResolver().ReadManifests(rootFolder, new JsonHelper(), new ModDataRecord[0]).ToArray();
|
||||||
IModMetadata mod = mods.FirstOrDefault();
|
IModMetadata mod = mods.FirstOrDefault();
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
Assert.AreEqual(1, mods.Length, 0, "Expected to find one manifest.");
|
Assert.AreEqual(1, mods.Length, 0, "Expected to find one manifest.");
|
||||||
Assert.IsNotNull(mod, "The loaded manifest shouldn't be null.");
|
Assert.IsNotNull(mod, "The loaded manifest shouldn't be null.");
|
||||||
Assert.AreEqual(null, mod.Compatibility, "The compatibility record should be null since we didn't provide one.");
|
Assert.AreEqual(null, mod.DataRecord, "The data record should be null since we didn't provide one.");
|
||||||
Assert.AreEqual(modFolder, mod.DirectoryPath, "The directory path doesn't match.");
|
Assert.AreEqual(modFolder, mod.DirectoryPath, "The directory path doesn't match.");
|
||||||
Assert.AreEqual(ModMetadataStatus.Found, mod.Status, "The status doesn't match.");
|
Assert.AreEqual(ModMetadataStatus.Found, mod.Status, "The status doesn't match.");
|
||||||
Assert.AreEqual(null, mod.Error, "The error should be null since parsing should have succeeded.");
|
Assert.AreEqual(null, mod.Error, "The error should be null since parsing should have succeeded.");
|
||||||
|
@ -136,12 +136,12 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
mock.VerifyGet(p => p.Status, Times.Once, "The validation did not check the manifest status.");
|
mock.VerifyGet(p => p.Status, Times.Once, "The validation did not check the manifest status.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test(Description = "Assert that validation fails if the mod has 'assume broken' compatibility.")]
|
[Test(Description = "Assert that validation fails if the mod has 'assume broken' status.")]
|
||||||
public void ValidateManifests_ModCompatibility_AssumeBroken_Fails()
|
public void ValidateManifests_ModStatus_AssumeBroken_Fails()
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
Mock<IModMetadata> mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true);
|
Mock<IModMetadata> mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true);
|
||||||
this.SetupMetadataForValidation(mock, new ModCompatibility { Status = ModStatus.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" } });
|
this.SetupMetadataForValidation(mock, new ModDataRecord { Status = ModStatus.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" } });
|
||||||
|
|
||||||
// act
|
// act
|
||||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"));
|
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"));
|
||||||
|
@ -211,7 +211,7 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
// arrange
|
// arrange
|
||||||
Mock<IModMetadata> mock = new Mock<IModMetadata>(MockBehavior.Strict);
|
Mock<IModMetadata> mock = new Mock<IModMetadata>(MockBehavior.Strict);
|
||||||
mock.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
mock.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
||||||
mock.Setup(p => p.Compatibility).Returns(() => null);
|
mock.Setup(p => p.DataRecord).Returns(() => null);
|
||||||
mock.Setup(p => p.Manifest).Returns(manifest);
|
mock.Setup(p => p.Manifest).Returns(manifest);
|
||||||
mock.Setup(p => p.DirectoryPath).Returns(modFolder);
|
mock.Setup(p => p.DirectoryPath).Returns(modFolder);
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
private Mock<IModMetadata> GetMetadata(IManifest manifest, bool allowStatusChange = false)
|
private Mock<IModMetadata> GetMetadata(IManifest manifest, bool allowStatusChange = false)
|
||||||
{
|
{
|
||||||
Mock<IModMetadata> mod = new Mock<IModMetadata>(MockBehavior.Strict);
|
Mock<IModMetadata> mod = new Mock<IModMetadata>(MockBehavior.Strict);
|
||||||
mod.Setup(p => p.Compatibility).Returns(() => null);
|
mod.Setup(p => p.DataRecord).Returns(() => null);
|
||||||
mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
||||||
mod.Setup(p => p.DisplayName).Returns(manifest.UniqueID);
|
mod.Setup(p => p.DisplayName).Returns(manifest.UniqueID);
|
||||||
mod.Setup(p => p.Manifest).Returns(manifest);
|
mod.Setup(p => p.Manifest).Returns(manifest);
|
||||||
|
@ -539,14 +539,14 @@ namespace StardewModdingAPI.Tests.Core
|
||||||
|
|
||||||
/// <summary>Set up a mock mod metadata for <see cref="ModResolver.ValidateManifests"/>.</summary>
|
/// <summary>Set up a mock mod metadata for <see cref="ModResolver.ValidateManifests"/>.</summary>
|
||||||
/// <param name="mod">The mock mod metadata.</param>
|
/// <param name="mod">The mock mod metadata.</param>
|
||||||
/// <param name="compatibility">The compatibility record to set.</param>
|
/// <param name="modRecord">The extra metadata about the mod from SMAPI's internal data (if any).</param>
|
||||||
private void SetupMetadataForValidation(Mock<IModMetadata> mod, ModCompatibility compatibility = null)
|
private void SetupMetadataForValidation(Mock<IModMetadata> mod, ModDataRecord modRecord = null)
|
||||||
{
|
{
|
||||||
mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
mod.Setup(p => p.Status).Returns(ModMetadataStatus.Found);
|
||||||
mod.Setup(p => p.Compatibility).Returns(() => null);
|
mod.Setup(p => p.DataRecord).Returns(() => null);
|
||||||
mod.Setup(p => p.Manifest).Returns(this.GetManifest());
|
mod.Setup(p => p.Manifest).Returns(this.GetManifest());
|
||||||
mod.Setup(p => p.DirectoryPath).Returns(Path.GetTempPath());
|
mod.Setup(p => p.DirectoryPath).Returns(Path.GetTempPath());
|
||||||
mod.Setup(p => p.Compatibility).Returns(compatibility);
|
mod.Setup(p => p.DataRecord).Returns(modRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using StardewModdingAPI.Framework.Models;
|
using StardewModdingAPI.Framework.Models;
|
||||||
using StardewModdingAPI.Framework.ModLoading;
|
using StardewModdingAPI.Framework.ModLoading;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework
|
namespace StardewModdingAPI.Framework
|
||||||
|
@ -18,8 +18,8 @@ namespace StardewModdingAPI.Framework
|
||||||
/// <summary>The mod manifest.</summary>
|
/// <summary>The mod manifest.</summary>
|
||||||
IManifest Manifest { get; }
|
IManifest Manifest { get; }
|
||||||
|
|
||||||
/// <summary>Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
|
/// <summary>>Metadata about the mod from SMAPI's internal data (if any).</summary>
|
||||||
ModCompatibility Compatibility { get; }
|
ModDataRecord DataRecord { get; }
|
||||||
|
|
||||||
/// <summary>The metadata resolution status.</summary>
|
/// <summary>The metadata resolution status.</summary>
|
||||||
ModMetadataStatus Status { get; }
|
ModMetadataStatus Status { get; }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using StardewModdingAPI.Framework.Models;
|
using StardewModdingAPI.Framework.Models;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.ModLoading
|
namespace StardewModdingAPI.Framework.ModLoading
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,8 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
/// <summary>The mod manifest.</summary>
|
/// <summary>The mod manifest.</summary>
|
||||||
public IManifest Manifest { get; }
|
public IManifest Manifest { get; }
|
||||||
|
|
||||||
/// <summary>Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
|
/// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary>
|
||||||
public ModCompatibility Compatibility { get; }
|
public ModDataRecord DataRecord { get; }
|
||||||
|
|
||||||
/// <summary>The metadata resolution status.</summary>
|
/// <summary>The metadata resolution status.</summary>
|
||||||
public ModMetadataStatus Status { get; private set; }
|
public ModMetadataStatus Status { get; private set; }
|
||||||
|
@ -37,13 +37,13 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
/// <param name="displayName">The mod's display name.</param>
|
/// <param name="displayName">The mod's display name.</param>
|
||||||
/// <param name="directoryPath">The mod's full directory path.</param>
|
/// <param name="directoryPath">The mod's full directory path.</param>
|
||||||
/// <param name="manifest">The mod manifest.</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="dataRecord">Metadata about the mod from SMAPI's internal data (if any).</param>
|
||||||
public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility)
|
public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModDataRecord dataRecord)
|
||||||
{
|
{
|
||||||
this.DisplayName = displayName;
|
this.DisplayName = displayName;
|
||||||
this.DirectoryPath = directoryPath;
|
this.DirectoryPath = directoryPath;
|
||||||
this.Manifest = manifest;
|
this.Manifest = manifest;
|
||||||
this.Compatibility = compatibility;
|
this.DataRecord = dataRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Set the mod status.</summary>
|
/// <summary>Set the mod status.</summary>
|
||||||
|
|
|
@ -17,11 +17,11 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
/// <summary>Get manifest metadata for each folder in the given root path.</summary>
|
/// <summary>Get manifest metadata for each folder in the given root path.</summary>
|
||||||
/// <param name="rootPath">The root path to search for mods.</param>
|
/// <param name="rootPath">The root path to search for mods.</param>
|
||||||
/// <param name="jsonHelper">The JSON helper with which to read manifests.</param>
|
/// <param name="jsonHelper">The JSON helper with which to read manifests.</param>
|
||||||
/// <param name="compatibilityRecords">Metadata about mods that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param>
|
/// <param name="dataRecords">Metadata about mods from SMAPI's internal data.</param>
|
||||||
/// <returns>Returns the manifests by relative folder.</returns>
|
/// <returns>Returns the manifests by relative folder.</returns>
|
||||||
public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModCompatibility> compatibilityRecords)
|
public IEnumerable<IModMetadata> ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable<ModDataRecord> dataRecords)
|
||||||
{
|
{
|
||||||
compatibilityRecords = compatibilityRecords.ToArray();
|
dataRecords = dataRecords.ToArray();
|
||||||
|
|
||||||
foreach (DirectoryInfo modDir in this.GetModFolders(rootPath))
|
foreach (DirectoryInfo modDir in this.GetModFolders(rootPath))
|
||||||
{
|
{
|
||||||
|
@ -54,15 +54,15 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate metadata
|
// validate metadata
|
||||||
ModCompatibility compatibility = null;
|
ModDataRecord dataRecord = null;
|
||||||
if (manifest != null)
|
if (manifest != null)
|
||||||
{
|
{
|
||||||
// get unique key for lookups
|
// get unique key for lookups
|
||||||
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
|
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
|
||||||
|
|
||||||
// get compatibility record
|
// get data record
|
||||||
compatibility = (
|
dataRecord = (
|
||||||
from mod in compatibilityRecords
|
from mod in dataRecords
|
||||||
where
|
where
|
||||||
mod.ID.Any(p => p.Matches(key, manifest))
|
mod.ID.Any(p => p.Matches(key, manifest))
|
||||||
&& (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
|
&& (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
|
||||||
|
@ -79,7 +79,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
? ModMetadataStatus.Found
|
? ModMetadataStatus.Found
|
||||||
: ModMetadataStatus.Failed;
|
: ModMetadataStatus.Failed;
|
||||||
|
|
||||||
yield return new ModMetadata(displayName, modDir.FullName, manifest, compatibility).SetStatus(status, error);
|
yield return new ModMetadata(displayName, modDir.FullName, manifest, dataRecord).SetStatus(status, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,22 +99,22 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
|
|
||||||
// validate compatibility
|
// validate compatibility
|
||||||
{
|
{
|
||||||
ModCompatibility compatibility = mod.Compatibility;
|
ModDataRecord dataRecord = mod.DataRecord;
|
||||||
switch (compatibility?.Status)
|
switch (dataRecord?.Status)
|
||||||
{
|
{
|
||||||
case ModStatus.Obsolete:
|
case ModStatus.Obsolete:
|
||||||
mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {compatibility.ReasonPhrase}");
|
mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {dataRecord.ReasonPhrase}");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ModStatus.AssumeBroken:
|
case ModStatus.AssumeBroken:
|
||||||
{
|
{
|
||||||
string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
|
string reasonPhrase = dataRecord.ReasonPhrase ?? "it's no longer compatible";
|
||||||
string error = $"{reasonPhrase}. Please check for a ";
|
string error = $"{reasonPhrase}. Please check for a ";
|
||||||
if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null)
|
if (mod.Manifest.Version.Equals(dataRecord.UpperVersion) && dataRecord.UpperVersionLabel == null)
|
||||||
error += "newer version";
|
error += "newer version";
|
||||||
else
|
else
|
||||||
error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}";
|
error += $"version newer than {dataRecord.UpperVersionLabel ?? dataRecord.UpperVersion.ToString()}";
|
||||||
error += " at " + string.Join(" or ", compatibility.UpdateUrls);
|
error += " at " + string.Join(" or ", dataRecord.UpdateUrls);
|
||||||
|
|
||||||
mod.SetStatus(ModMetadataStatus.Failed, error);
|
mod.SetStatus(ModMetadataStatus.Failed, error);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.Models
|
namespace StardewModdingAPI.Framework.Models
|
||||||
{
|
{
|
||||||
/// <summary>Uniquely identifies a mod for compatibility checks.</summary>
|
/// <summary>Uniquely identifies a mod in SMAPI's internal data.</summary>
|
||||||
internal class ModCompatibilityID
|
internal class ModDataID
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Accessors
|
** Accessors
|
||||||
|
@ -23,11 +23,11 @@ namespace StardewModdingAPI.Framework.Models
|
||||||
** Public methods
|
** Public methods
|
||||||
*********/
|
*********/
|
||||||
/// <summary>Construct an instance.</summary>
|
/// <summary>Construct an instance.</summary>
|
||||||
public ModCompatibilityID() { }
|
public ModDataID() { }
|
||||||
|
|
||||||
/// <summary>Construct an instance.</summary>
|
/// <summary>Construct an instance.</summary>
|
||||||
/// <param name="data">The mod ID or a JSON string matching the <see cref="ModCompatibilityID"/> fields.</param>
|
/// <param name="data">The mod ID or a JSON string matching the <see cref="ModDataID"/> fields.</param>
|
||||||
public ModCompatibilityID(string data)
|
public ModDataID(string data)
|
||||||
{
|
{
|
||||||
// JSON can be stuffed into the ID string as a convenience hack to keep JSON mod lists
|
// JSON can be stuffed into the ID string as a convenience hack to keep JSON mod lists
|
||||||
// formatted readably. The tradeoff is that the format is a bit more magical, but that's
|
// formatted readably. The tradeoff is that the format is a bit more magical, but that's
|
|
@ -3,15 +3,15 @@ using StardewModdingAPI.Framework.Serialisation;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.Models
|
namespace StardewModdingAPI.Framework.Models
|
||||||
{
|
{
|
||||||
/// <summary>Metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary>
|
/// <summary>Metadata about a mod from SMAPI's internal data.</summary>
|
||||||
internal class ModCompatibility
|
internal class ModDataRecord
|
||||||
{
|
{
|
||||||
/*********
|
/*********
|
||||||
** Accessors
|
** Accessors
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The unique mod IDs.</summary>
|
/// <summary>The unique mod IDs.</summary>
|
||||||
[JsonConverter(typeof(SFieldConverter))]
|
[JsonConverter(typeof(SFieldConverter))]
|
||||||
public ModCompatibilityID[] ID { get; set; }
|
public ModDataID[] ID { get; set; }
|
||||||
|
|
||||||
/// <summary>The mod name.</summary>
|
/// <summary>The mod name.</summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
|
@ -21,7 +21,7 @@ namespace StardewModdingAPI.Framework.Models
|
||||||
/// <summary>Whether SMAPI should log more information about the game context.</summary>
|
/// <summary>Whether SMAPI should log more information about the game context.</summary>
|
||||||
public bool VerboseLogging { get; set; }
|
public bool VerboseLogging { get; set; }
|
||||||
|
|
||||||
/// <summary>A list of mod versions which should be considered compatible or incompatible regardless of whether SMAPI detects incompatible code.</summary>
|
/// <summary>Extra metadata about mods.</summary>
|
||||||
public ModCompatibility[] ModCompatibility { get; set; }
|
public ModDataRecord[] ModData { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace StardewModdingAPI.Framework.Serialisation
|
||||||
return
|
return
|
||||||
objectType == typeof(ISemanticVersion)
|
objectType == typeof(ISemanticVersion)
|
||||||
|| objectType == typeof(IManifestDependency[])
|
|| objectType == typeof(IManifestDependency[])
|
||||||
|| objectType == typeof(ModCompatibilityID[]);
|
|| objectType == typeof(ModDataID[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Reads the JSON representation of the object.</summary>
|
/// <summary>Reads the JSON representation of the object.</summary>
|
||||||
|
@ -83,14 +83,14 @@ namespace StardewModdingAPI.Framework.Serialisation
|
||||||
}
|
}
|
||||||
|
|
||||||
// mod compatibility ID
|
// mod compatibility ID
|
||||||
if (objectType == typeof(ModCompatibilityID[]))
|
if (objectType == typeof(ModDataID[]))
|
||||||
{
|
{
|
||||||
List<ModCompatibilityID> result = new List<ModCompatibilityID>();
|
List<ModDataID> result = new List<ModDataID>();
|
||||||
foreach (JToken child in JArray.Load(reader).Children())
|
foreach (JToken child in JArray.Load(reader).Children())
|
||||||
{
|
{
|
||||||
result.Add(child is JValue value
|
result.Add(child is JValue value
|
||||||
? new ModCompatibilityID(value.Value<string>())
|
? new ModDataID(value.Value<string>())
|
||||||
: child.ToObject<ModCompatibilityID>()
|
: child.ToObject<ModDataID>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
|
|
|
@ -347,7 +347,7 @@ namespace StardewModdingAPI
|
||||||
ModResolver resolver = new ModResolver();
|
ModResolver resolver = new ModResolver();
|
||||||
|
|
||||||
// load manifests
|
// load manifests
|
||||||
IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModCompatibility).ToArray();
|
IModMetadata[] mods = resolver.ReadManifests(Constants.ModPath, new JsonHelper(), this.Settings.ModData).ToArray();
|
||||||
resolver.ValidateManifests(mods, Constants.ApiVersion);
|
resolver.ValidateManifests(mods, Constants.ApiVersion);
|
||||||
|
|
||||||
// process dependencies
|
// process dependencies
|
||||||
|
@ -640,7 +640,7 @@ namespace StardewModdingAPI
|
||||||
Assembly modAssembly;
|
Assembly modAssembly;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.Compatibility?.Status == ModStatus.AssumeCompatible);
|
modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.DataRecord?.Status == ModStatus.AssumeCompatible);
|
||||||
}
|
}
|
||||||
catch (IncompatibleInstructionException ex)
|
catch (IncompatibleInstructionException ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha
|
||||||
* load a mod regardless of compatibility checks, add a "Compatibility": "AssumeCompatible" field.
|
* load a mod regardless of compatibility checks, add a "Compatibility": "AssumeCompatible" field.
|
||||||
* Changing this field is not recommended and may destabilise your game.
|
* Changing this field is not recommended and may destabilise your game.
|
||||||
*/
|
*/
|
||||||
"ModCompatibility": [
|
"ModData": [
|
||||||
{
|
{
|
||||||
"Name": "AccessChestAnywhere",
|
"Name": "AccessChestAnywhere",
|
||||||
"ID": [ "AccessChestAnywhere" ],
|
"ID": [ "AccessChestAnywhere" ],
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
<Compile Include="Framework\Utilities\Countdown.cs" />
|
<Compile Include="Framework\Utilities\Countdown.cs" />
|
||||||
<Compile Include="Framework\GameVersion.cs" />
|
<Compile Include="Framework\GameVersion.cs" />
|
||||||
<Compile Include="Framework\IModMetadata.cs" />
|
<Compile Include="Framework\IModMetadata.cs" />
|
||||||
<Compile Include="Framework\Models\ModCompatibilityID.cs" />
|
<Compile Include="Framework\Models\ModDataID.cs" />
|
||||||
<Compile Include="Framework\ModHelpers\BaseHelper.cs" />
|
<Compile Include="Framework\ModHelpers\BaseHelper.cs" />
|
||||||
<Compile Include="Framework\ModHelpers\CommandHelper.cs" />
|
<Compile Include="Framework\ModHelpers\CommandHelper.cs" />
|
||||||
<Compile Include="Framework\ModHelpers\ContentHelper.cs" />
|
<Compile Include="Framework\ModHelpers\ContentHelper.cs" />
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
<Compile Include="Framework\DeprecationLevel.cs" />
|
<Compile Include="Framework\DeprecationLevel.cs" />
|
||||||
<Compile Include="Framework\DeprecationManager.cs" />
|
<Compile Include="Framework\DeprecationManager.cs" />
|
||||||
<Compile Include="Framework\InternalExtensions.cs" />
|
<Compile Include="Framework\InternalExtensions.cs" />
|
||||||
<Compile Include="Framework\Models\ModCompatibility.cs" />
|
<Compile Include="Framework\Models\ModDataRecord.cs" />
|
||||||
<Compile Include="Framework\ModLoading\AssemblyLoader.cs" />
|
<Compile Include="Framework\ModLoading\AssemblyLoader.cs" />
|
||||||
<Compile Include="Framework\Reflection\CacheEntry.cs" />
|
<Compile Include="Framework\Reflection\CacheEntry.cs" />
|
||||||
<Compile Include="Framework\Reflection\PrivateField.cs" />
|
<Compile Include="Framework\Reflection\PrivateField.cs" />
|
||||||
|
|
Loading…
Reference in New Issue