diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 2 | ||||
-rw-r--r-- | src/StardewModdingAPI.Toolkit/SemanticVersion.cs | 20 | ||||
-rw-r--r-- | src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs | 24 |
3 files changed, 32 insertions, 14 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index eff7cb3b..5fb2dc61 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -902,11 +902,13 @@ namespace StardewModdingAPI.Framework return false; } +#if !SMAPI_3_0_STRICT // add deprecation warning for old version format { if (mod.Manifest?.Version is Toolkit.SemanticVersion version && version.IsLegacyFormat) this.DeprecationManager.Warn(mod.DisplayName, "non-string manifest version", "2.8", DeprecationLevel.Notice); } +#endif // validate dependencies // Although dependences are validated before mods are loaded, a dependency may have failed to load. diff --git a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs index 2d0bc033..19da0a76 100644 --- a/src/StardewModdingAPI.Toolkit/SemanticVersion.cs +++ b/src/StardewModdingAPI.Toolkit/SemanticVersion.cs @@ -39,17 +39,17 @@ namespace StardewModdingAPI.Toolkit /// <summary>The patch version for backwards-compatible bug fixes.</summary> public int PatchVersion { get; } + /// <summary>An optional prerelease tag.</summary> + public string PrereleaseTag { get; } + #if !SMAPI_3_0_STRICT /// <summary>An optional prerelease tag.</summary> [Obsolete("Use " + nameof(ISemanticVersion.PrereleaseTag) + " instead")] public string Build => this.PrereleaseTag; -#endif - - /// <summary>An optional prerelease tag.</summary> - public string PrereleaseTag { get; } /// <summary>Whether the version was parsed from the legacy object format.</summary> public bool IsLegacyFormat { get; } +#endif /********* @@ -59,15 +59,21 @@ namespace StardewModdingAPI.Toolkit /// <param name="major">The major version incremented for major API changes.</param> /// <param name="minor">The minor version incremented for backwards-compatible changes.</param> /// <param name="patch">The patch version for backwards-compatible fixes.</param> - /// <param name="tag">An optional prerelease tag.</param> + /// <param name="prereleaseTag">An optional prerelease tag.</param> /// <param name="isLegacyFormat">Whether the version was parsed from the legacy object format.</param> - public SemanticVersion(int major, int minor, int patch, string tag = null, bool isLegacyFormat = false) + public SemanticVersion(int major, int minor, int patch, string prereleaseTag = null +#if !SMAPI_3_0_STRICT + , bool isLegacyFormat = false +#endif + ) { this.MajorVersion = major; this.MinorVersion = minor; this.PatchVersion = patch; - this.PrereleaseTag = this.GetNormalisedTag(tag); + this.PrereleaseTag = this.GetNormalisedTag(prereleaseTag); +#if !SMAPI_3_0_STRICT this.IsLegacyFormat = isLegacyFormat; +#endif this.AssertValid(); } diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs index e0e185c9..aca06849 100644 --- a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs +++ b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs @@ -63,14 +63,24 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Converters /// <param name="obj">The JSON object to read.</param> private ISemanticVersion ReadObject(JObject obj) { - int major = obj.ValueIgnoreCase<int>("MajorVersion"); - int minor = obj.ValueIgnoreCase<int>("MinorVersion"); - int patch = obj.ValueIgnoreCase<int>("PatchVersion"); - string build = obj.ValueIgnoreCase<string>("Build"); - if (build == "0") - build = null; // '0' from incorrect examples in old SMAPI documentation + int major = obj.ValueIgnoreCase<int>(nameof(ISemanticVersion.MajorVersion)); + int minor = obj.ValueIgnoreCase<int>(nameof(ISemanticVersion.MinorVersion)); + int patch = obj.ValueIgnoreCase<int>(nameof(ISemanticVersion.PatchVersion)); + string prereleaseTag = obj.ValueIgnoreCase<string>(nameof(ISemanticVersion.PrereleaseTag)); +#if !SMAPI_3_0_STRICT + if (string.IsNullOrWhiteSpace(prereleaseTag)) + { + prereleaseTag = obj.ValueIgnoreCase<string>("Build"); + if (prereleaseTag == "0") + prereleaseTag = null; // '0' from incorrect examples in old SMAPI documentation + } +#endif - return new SemanticVersion(major, minor, patch, build, isLegacyFormat: true); + return new SemanticVersion(major, minor, patch, prereleaseTag +#if !SMAPI_3_0_STRICT + , isLegacyFormat: true +#endif + ); } /// <summary>Read a JSON string.</summary> |