diff options
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/LegacyManifestVersion.cs | 26 | ||||
-rw-r--r-- | src/SMAPI/Framework/Serialisation/SFieldConverter.cs | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/LegacyManifestVersion.cs b/src/SMAPI/Framework/LegacyManifestVersion.cs new file mode 100644 index 00000000..454b9137 --- /dev/null +++ b/src/SMAPI/Framework/LegacyManifestVersion.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; + +namespace StardewModdingAPI.Framework +{ + /// <summary>An implementation of <see cref="ISemanticVersion"/> that hamdles the legacy <see cref="IManifest"/> version format.</summary> + internal class LegacyManifestVersion : SemanticVersion + { + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="majorVersion">The major version incremented for major API changes.</param> + /// <param name="minorVersion">The minor version incremented for backwards-compatible changes.</param> + /// <param name="patchVersion">The patch version for backwards-compatible bug fixes.</param> + /// <param name="build">An optional build tag.</param> + [JsonConstructor] + public LegacyManifestVersion(int majorVersion, int minorVersion, int patchVersion, string build = null) + : base( + majorVersion, + minorVersion, + patchVersion, + build != "0" ? build : null // '0' from incorrect examples in old SMAPI documentation + ) + { } + } +} diff --git a/src/SMAPI/Framework/Serialisation/SFieldConverter.cs b/src/SMAPI/Framework/Serialisation/SFieldConverter.cs index 917c950d..6e068599 100644 --- a/src/SMAPI/Framework/Serialisation/SFieldConverter.cs +++ b/src/SMAPI/Framework/Serialisation/SFieldConverter.cs @@ -51,7 +51,7 @@ namespace StardewModdingAPI.Framework.Serialisation int minor = obj.Value<int>(nameof(ISemanticVersion.MinorVersion)); int patch = obj.Value<int>(nameof(ISemanticVersion.PatchVersion)); string build = obj.Value<string>(nameof(ISemanticVersion.Build)); - return new SemanticVersion(major, minor, patch, build); + return new LegacyManifestVersion(major, minor, patch, build); } case JTokenType.String: |