From 8bcc80a33d42f5c6f044533bb151d75901de912f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 21:35:07 -0400 Subject: rename mod compatibility type for broader use (#361) --- src/StardewModdingAPI.Tests/Core/ModResolverTests.cs | 2 +- src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs | 2 +- .../Framework/Models/ModCompatibility.cs | 6 +++--- .../Framework/Models/ModCompatibilityType.cs | 12 ------------ src/StardewModdingAPI/Framework/Models/ModStatus.cs | 15 +++++++++++++++ src/StardewModdingAPI/Program.cs | 2 +- src/StardewModdingAPI/StardewModdingAPI.csproj | 2 +- 7 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs create mode 100644 src/StardewModdingAPI/Framework/Models/ModStatus.cs diff --git a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs index 7a81c68c..bc3a0c8c 100644 --- a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs +++ b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs @@ -141,7 +141,7 @@ namespace StardewModdingAPI.Tests.Core { // arrange Mock mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true); - this.SetupMetadataForValidation(mock, new ModCompatibility { Compatibility = ModCompatibilityType.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" } }); + this.SetupMetadataForValidation(mock, new ModCompatibility { Status = ModStatus.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" } }); // act new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0")); diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index 87b6a99c..6a971c15 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -107,7 +107,7 @@ namespace StardewModdingAPI.Framework.ModLoading // validate compatibility { ModCompatibility compatibility = mod.Compatibility; - if (compatibility?.Compatibility == ModCompatibilityType.AssumeBroken) + if (compatibility?.Status == ModStatus.AssumeBroken) { string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible"; string error = $"{reasonPhrase}. Please check for a "; diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs index d3a9c533..7489a306 100644 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using StardewModdingAPI.Framework.Serialisation; namespace StardewModdingAPI.Framework.Models @@ -34,7 +34,7 @@ namespace StardewModdingAPI.Framework.Models /// "this version is incompatible with the latest version of the game" public string ReasonPhrase { get; set; } - /// Indicates how SMAPI should consider the mod. - public ModCompatibilityType Compatibility { get; set; } = ModCompatibilityType.AssumeBroken; + /// Indicates how SMAPI should treat the mod. + public ModStatus Status { get; set; } = ModStatus.AssumeBroken; } } diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs deleted file mode 100644 index 35edec5e..00000000 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace StardewModdingAPI.Framework.Models -{ - /// Indicates how SMAPI should consider a mod. - internal enum ModCompatibilityType - { - /// Assume the mod is not compatible, even if SMAPI doesn't detect any incompatible code. - AssumeBroken = 0, - - /// Assume the mod is compatible, even if SMAPI detects incompatible code. - AssumeCompatible = 1 - } -} diff --git a/src/StardewModdingAPI/Framework/Models/ModStatus.cs b/src/StardewModdingAPI/Framework/Models/ModStatus.cs new file mode 100644 index 00000000..4ab0b790 --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/ModStatus.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Framework.Models +{ + /// Indicates how SMAPI should treat a mod. + internal enum ModStatus + { + /// Don't override the status. + None = 0, + + /// Assume the mod is not compatible, even if SMAPI doesn't detect any incompatible code. + AssumeBroken = 0, + + /// Assume the mod is compatible, even if SMAPI detects incompatible code. + AssumeCompatible = 1 + } +} diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 8f32b9eb..234572a6 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -640,7 +640,7 @@ namespace StardewModdingAPI Assembly modAssembly; try { - modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.Compatibility?.Compatibility == ModCompatibilityType.AssumeCompatible); + modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.Compatibility?.Status == ModStatus.AssumeCompatible); } catch (IncompatibleInstructionException ex) { diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index 685bef1e..46f2ffb1 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -166,7 +166,7 @@ - + -- cgit