diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 2 | ||||
-rw-r--r-- | src/StardewModdingAPI/SemanticVersion.cs | 31 |
2 files changed, 17 insertions, 16 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 9de7496e..8a87c15d 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -381,7 +381,7 @@ namespace StardewModdingAPI continue; } } - catch (FormatException ex) when (ex.Message.Contains("not a semantic version")) + catch (FormatException ex) when (ex.Message.Contains("not a valid semantic version")) { Program.Monitor.Log($"{errorPrefix}: the mod specified an invalid minimum SMAPI version '{manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.Version}.", LogLevel.Error); continue; diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs index 9694375e..daefda51 100644 --- a/src/StardewModdingAPI/SemanticVersion.cs +++ b/src/StardewModdingAPI/SemanticVersion.cs @@ -53,6 +53,21 @@ namespace StardewModdingAPI this.Build = build; } + /// <summary>Construct an instance.</summary> + /// <param name="version">The semantic version string.</param> + /// <exception cref="FormatException">The <paramref name="version"/> is not a valid semantic version.</exception> + internal SemanticVersion(string version) + { + var match = SemanticVersion.Regex.Match(version); + if (!match.Success) + throw new FormatException($"The input '{version}' is not a valid semantic version."); + + 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; + } + /// <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> /// <remarks>The implementation is defined by Semantic Version 2.0 (http://semver.org/).</remarks> @@ -141,20 +156,6 @@ namespace StardewModdingAPI /********* ** Private methods *********/ - /// <summary>Construct an instance.</summary> - /// <param name="version">The semantic version string.</param> - internal SemanticVersion(string version) - { - var match = SemanticVersion.Regex.Match(version); - if (!match.Success) - throw new FormatException($"The input '{version}' is not a semantic version."); - - 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; - } - /// <summary>Get a normalised build tag.</summary> /// <param name="tag">The tag to normalise.</param> private string GetNormalisedTag(string tag) @@ -167,4 +168,4 @@ namespace StardewModdingAPI return tag; } } -}
\ No newline at end of file +} |