diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Tests/Utilities/SemanticVersionTests.cs | 12 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/SemanticVersion.cs | 14 | ||||
-rw-r--r-- | src/SMAPI/Framework/GameVersion.cs | 3 |
3 files changed, 13 insertions, 16 deletions
diff --git a/src/SMAPI.Tests/Utilities/SemanticVersionTests.cs b/src/SMAPI.Tests/Utilities/SemanticVersionTests.cs index 8da64c27..c91ec27f 100644 --- a/src/SMAPI.Tests/Utilities/SemanticVersionTests.cs +++ b/src/SMAPI.Tests/Utilities/SemanticVersionTests.cs @@ -18,10 +18,10 @@ namespace SMAPI.Tests.Utilities ** Constructor ****/ [Test(Description = "Assert that the constructor sets the expected values for all valid versions when constructed from a string.")] - [TestCase("1.0", ExpectedResult = "1.0")] - [TestCase("1.0.0", ExpectedResult = "1.0")] + [TestCase("1.0", ExpectedResult = "1.0.0")] + [TestCase("1.0.0", ExpectedResult = "1.0.0")] [TestCase("3000.4000.5000", ExpectedResult = "3000.4000.5000")] - [TestCase("1.2-some-tag.4", ExpectedResult = "1.2-some-tag.4")] + [TestCase("1.2-some-tag.4", ExpectedResult = "1.2.0-some-tag.4")] [TestCase("1.2.3-some-tag.4", ExpectedResult = "1.2.3-some-tag.4")] [TestCase("1.2.3-SoME-tAg.4", ExpectedResult = "1.2.3-SoME-tAg.4")] [TestCase("1.2.3-some-tag.4 ", ExpectedResult = "1.2.3-some-tag.4")] @@ -31,7 +31,7 @@ namespace SMAPI.Tests.Utilities } [Test(Description = "Assert that the constructor sets the expected values for all valid versions when constructed from the individual numbers.")] - [TestCase(1, 0, 0, null, ExpectedResult = "1.0")] + [TestCase(1, 0, 0, null, ExpectedResult = "1.0.0")] [TestCase(3000, 4000, 5000, null, ExpectedResult = "3000.4000.5000")] [TestCase(1, 2, 3, "", ExpectedResult = "1.2.3")] [TestCase(1, 2, 3, " ", ExpectedResult = "1.2.3")] @@ -66,7 +66,7 @@ namespace SMAPI.Tests.Utilities } [Test(Description = "Assert that the constructor sets the expected values for all valid versions when constructed from an assembly version.")] - [TestCase(1, 0, 0, ExpectedResult = "1.0")] + [TestCase(1, 0, 0, ExpectedResult = "1.0.0")] [TestCase(1, 2, 3, ExpectedResult = "1.2.3")] [TestCase(3000, 4000, 5000, ExpectedResult = "3000.4000.5000")] public string Constructor_FromAssemblyVersion(int major, int minor, int patch) @@ -247,7 +247,7 @@ namespace SMAPI.Tests.Utilities ** Serializable ****/ [Test(Description = "Assert that SemanticVersion can be round-tripped through JSON with no special configuration.")] - [TestCase("1.0")] + [TestCase("1.0.0")] public void Serializable(string versionStr) { // act diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index 6d5d65ac..2ce3578e 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -172,16 +172,10 @@ namespace StardewModdingAPI.Toolkit /// <summary>Get a string representation of the version.</summary> public override string ToString() { - // version - string result = this.PatchVersion != 0 - ? $"{this.MajorVersion}.{this.MinorVersion}.{this.PatchVersion}" - : $"{this.MajorVersion}.{this.MinorVersion}"; - - // tag - string tag = this.PrereleaseTag; - if (tag != null) - result += $"-{tag}"; - return result; + string version = $"{this.MajorVersion}.{this.MinorVersion}.{this.PatchVersion}"; + if (this.PrereleaseTag != null) + version += $"-{this.PrereleaseTag}"; + return version; } /// <summary>Parse a version string without throwing an exception if it fails.</summary> diff --git a/src/SMAPI/Framework/GameVersion.cs b/src/SMAPI/Framework/GameVersion.cs index b9ef12c8..cd88895c 100644 --- a/src/SMAPI/Framework/GameVersion.cs +++ b/src/SMAPI/Framework/GameVersion.cs @@ -12,6 +12,7 @@ namespace StardewModdingAPI.Framework /// <summary>A mapping of game to semantic versions.</summary> private static readonly IDictionary<string, string> VersionMap = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) { + ["1.0"] = "1.0.0", ["1.01"] = "1.0.1", ["1.02"] = "1.0.2", ["1.03"] = "1.0.3", @@ -23,6 +24,8 @@ namespace StardewModdingAPI.Framework ["1.07"] = "1.0.7", ["1.07a"] = "1.0.8-prerelease1", ["1.08"] = "1.0.8", + ["1.1"] = "1.1.0", + ["1.2"] = "1.2.0", ["1.11"] = "1.1.1" }; |