summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Toolkit/Serialisation/Converters
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-07 13:40:44 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2018-12-07 13:40:44 -0500
commita78b1935928919694dfe8de823a1accd6d222732 (patch)
tree3f17b6087cf2749e52c1e237de17e2e9addb6c06 /src/StardewModdingAPI.Toolkit/Serialisation/Converters
parent4cd9eda1591c3908bf80b60c2902491a7595ee27 (diff)
parent8901218418693d610a17b22fe789ba6279f63446 (diff)
downloadSMAPI-a78b1935928919694dfe8de823a1accd6d222732.tar.gz
SMAPI-a78b1935928919694dfe8de823a1accd6d222732.tar.bz2
SMAPI-a78b1935928919694dfe8de823a1accd6d222732.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Serialisation/Converters')
-rw-r--r--src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs24
1 files changed, 17 insertions, 7 deletions
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>