From 24b824644d708a514614b4e30b41567ea87902cc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 20 Jul 2017 00:01:40 -0400 Subject: make semantic versions equatable in 2.0 --- src/StardewModdingAPI/ISemanticVersion.cs | 3 +++ src/StardewModdingAPI/SemanticVersion.cs | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/StardewModdingAPI') diff --git a/src/StardewModdingAPI/ISemanticVersion.cs b/src/StardewModdingAPI/ISemanticVersion.cs index 27a2f67d..c1a4ca3a 100644 --- a/src/StardewModdingAPI/ISemanticVersion.cs +++ b/src/StardewModdingAPI/ISemanticVersion.cs @@ -4,6 +4,9 @@ namespace StardewModdingAPI { /// A semantic version with an optional release tag. public interface ISemanticVersion : IComparable +#if !SMAPI_1_x + , IEquatable +#endif { /********* ** Accessors diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs index 4b27c819..f30c43cd 100644 --- a/src/StardewModdingAPI/SemanticVersion.cs +++ b/src/StardewModdingAPI/SemanticVersion.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text.RegularExpressions; namespace StardewModdingAPI @@ -178,6 +178,16 @@ namespace StardewModdingAPI return this.IsBetween(new SemanticVersion(min), new SemanticVersion(max)); } +#if !SMAPI_1_x + /// Indicates whether the current object is equal to another object of the same type. + /// true if the current object is equal to the parameter; otherwise, false. + /// An object to compare with this object. + public bool Equals(ISemanticVersion other) + { + return other != null && this.CompareTo(other) == 0; + } +#endif + /// Get a string representation of the version. public override string ToString() { -- cgit