summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/SemanticVersion.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-13 18:20:09 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-13 18:20:09 -0400
commit63edebaef1019ce103f5a86d55e1d1c4eb8d371c (patch)
treea61b1ebd08324477b049699b63f405a5025555d6 /src/StardewModdingAPI/SemanticVersion.cs
parent66d2b5746ab063b89ca42525a78e217e71d00858 (diff)
downloadSMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.tar.gz
SMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.tar.bz2
SMAPI-63edebaef1019ce103f5a86d55e1d1c4eb8d371c.zip
decouple mod metadata resolution from main SMAPI logic (#285)
This makes the logic more self-contained for eventual unit testing, and makes failed mods available during dependency resolution so we can make errors more relevant.
Diffstat (limited to 'src/StardewModdingAPI/SemanticVersion.cs')
-rw-r--r--src/StardewModdingAPI/SemanticVersion.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/SemanticVersion.cs b/src/StardewModdingAPI/SemanticVersion.cs
index db25dc11..a2adb657 100644
--- a/src/StardewModdingAPI/SemanticVersion.cs
+++ b/src/StardewModdingAPI/SemanticVersion.cs
@@ -182,6 +182,23 @@ namespace StardewModdingAPI
return result;
}
+ /// <summary>Parse a version string without throwing an exception if it fails.</summary>
+ /// <param name="version">The version string.</param>
+ /// <param name="parsed">The parsed representation.</param>
+ /// <returns>Returns whether parsing the version succeeded.</returns>
+ internal static bool TryParse(string version, out ISemanticVersion parsed)
+ {
+ try
+ {
+ parsed = new SemanticVersion(version);
+ return true;
+ }
+ catch
+ {
+ parsed = null;
+ return false;
+ }
+ }
/*********
** Private methods