diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-05 14:55:46 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-05 14:55:46 -0400 |
commit | dbb9bd84306830456032778fc11fb9a34dd140c7 (patch) | |
tree | 0219cab065bfffbbbb9b048b6a30044f510be2c5 /src/StardewModdingAPI/SemanticVersion.cs | |
parent | 9c9833c9086b758589dafee10243e3bf47e12d73 (diff) | |
parent | 4675da0600edf6781cd740549ad0a175b606fc1e (diff) | |
download | SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.tar.gz SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.tar.bz2 SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.zip |
Merge branch 'develop-1.9' into stable
Diffstat (limited to 'src/StardewModdingAPI/SemanticVersion.cs')
-rw-r--r-- | src/StardewModdingAPI/SemanticVersion.cs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs index c29f2cf7..9610562f 100644 --- a/src/StardewModdingAPI/SemanticVersion.cs +++ b/src/StardewModdingAPI/SemanticVersion.cs @@ -13,28 +13,21 @@ namespace StardewModdingAPI /// <remarks>Derived from https://github.com/maxhauser/semver.</remarks> private static readonly Regex Regex = new Regex(@"^(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?(?<build>.*)$", RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture); - /// <summary>The backing field for <see cref="Build"/>.</summary> - private string _build; - /********* ** Accessors *********/ /// <summary>The major version incremented for major API changes.</summary> - public int MajorVersion { get; set; } + public int MajorVersion { get; } /// <summary>The minor version incremented for backwards-compatible changes.</summary> - public int MinorVersion { get; set; } + public int MinorVersion { get; } /// <summary>The patch version for backwards-compatible bug fixes.</summary> - public int PatchVersion { get; set; } + public int PatchVersion { get; } /// <summary>An optional build tag.</summary> - public string Build - { - get { return this._build; } - set { this._build = this.GetNormalisedTag(value); } - } + public string Build { get; } /********* @@ -50,7 +43,7 @@ namespace StardewModdingAPI this.MajorVersion = major; this.MinorVersion = minor; this.PatchVersion = patch; - this.Build = build; + this.Build = this.GetNormalisedTag(build); } /// <summary>Construct an instance.</summary> @@ -65,14 +58,18 @@ namespace StardewModdingAPI this.MajorVersion = int.Parse(match.Groups["major"].Value); this.MinorVersion = match.Groups["minor"].Success ? int.Parse(match.Groups["minor"].Value) : 0; this.PatchVersion = match.Groups["patch"].Success ? int.Parse(match.Groups["patch"].Value) : 0; - this.Build = match.Groups["build"].Success ? match.Groups["build"].Value : null; + this.Build = match.Groups["build"].Success ? this.GetNormalisedTag(match.Groups["build"].Value) : null; } /// <summary>Get an integer indicating whether this version precedes (less than 0), supercedes (more than 0), or is equivalent to (0) the specified version.</summary> /// <param name="other">The version to compare with this instance.</param> + /// <exception cref="ArgumentNullException">The <paramref name="other"/> value is null.</exception> /// <remarks>The implementation is defined by Semantic Version 2.0 (http://semver.org/).</remarks> public int CompareTo(ISemanticVersion other) { + if(other == null) + throw new ArgumentNullException(nameof(other)); + const int same = 0; const int curNewer = 1; const int curOlder = -1; |