summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-04 16:50:00 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-04 16:50:00 -0500
commit88dce820d52f7e09ce5424e13b34d6c10d5868ed (patch)
tree5a85bf951ebffa09215f0035ef3d6b5c4bf3f9d5
parent01c612bc4aca5a1d8921432c94956f4d170d4d4b (diff)
downloadSMAPI-88dce820d52f7e09ce5424e13b34d6c10d5868ed.tar.gz
SMAPI-88dce820d52f7e09ce5424e13b34d6c10d5868ed.tar.bz2
SMAPI-88dce820d52f7e09ce5424e13b34d6c10d5868ed.zip
no longer omit zero patch numbers when formatting versions
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI.Tests/Utilities/SemanticVersionTests.cs12
-rw-r--r--src/SMAPI.Toolkit/SemanticVersion.cs14
-rw-r--r--src/SMAPI/Framework/GameVersion.cs3
4 files changed, 14 insertions, 16 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 7cd7b52b..1d933f96 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -107,6 +107,7 @@ For modders:
* Trace logs for a broken mod now list all detected issues (instead of the first one).
* Trace logs when loading mods are now more clear.
* Clarified update-check errors for mods with multiple update keys.
+ * `SemanticVersion` no longer omits `.0` patch numbers when formatting versions, for better [semver](https://semver.org/) conformity (e.g. `3.0` is now formatted as `3.0.0`).
* Updated dependencies (including Json.NET 11.0.2 → 12.0.2 and Mono.Cecil 0.10.1 → 0.11).
* Fixes:
* Fixed custom maps loaded from `.xnb` files not having their tilesheet paths automatically adjusted.
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"
};