From 6a6001c7e6a03ff6fb0da992a87c6ef30d6bc952 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 3 May 2018 00:14:35 -0400 Subject: add semanticVersion.IsPrerelease() --- src/SMAPI/Framework/Models/SConfig.cs | 2 +- src/SMAPI/ISemanticVersion.cs | 3 +++ src/SMAPI/Program.cs | 2 +- src/SMAPI/SemanticVersion.cs | 6 ++++++ 4 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs index be84a6b9..b732921f 100644 --- a/src/SMAPI/Framework/Models/SConfig.cs +++ b/src/SMAPI/Framework/Models/SConfig.cs @@ -13,7 +13,7 @@ namespace StardewModdingAPI.Framework.Models public bool CheckForUpdates { get; set; } /// Whether to show beta versions as valid updates. - public bool UseBetaChannel { get; set; } = Constants.ApiVersion.Build != null; + public bool UseBetaChannel { get; set; } = Constants.ApiVersion.IsPrerelease(); /// SMAPI's GitHub project name, used to perform update checks. public string GitHubProjectName { get; set; } diff --git a/src/SMAPI/ISemanticVersion.cs b/src/SMAPI/ISemanticVersion.cs index 0483c97b..961ef777 100644 --- a/src/SMAPI/ISemanticVersion.cs +++ b/src/SMAPI/ISemanticVersion.cs @@ -24,6 +24,9 @@ namespace StardewModdingAPI /********* ** Accessors *********/ + /// Whether this is a pre-release version. + bool IsPrerelease(); + /// Get whether this version is older than the specified version. /// The version to compare with this instance. bool IsOlderThan(ISemanticVersion other); diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index ba3e238d..64520ccf 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -670,7 +670,7 @@ namespace StardewModdingAPI return newVersion != null && newVersion.IsNewerThan(currentVersion) - && (useBetaChannel || newVersion.Build == null); + && (useBetaChannel || !newVersion.IsPrerelease()); } /// Create a directory path if it doesn't exist. diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs index 0f2a5cb0..9db1cf14 100644 --- a/src/SMAPI/SemanticVersion.cs +++ b/src/SMAPI/SemanticVersion.cs @@ -55,6 +55,12 @@ namespace StardewModdingAPI public SemanticVersion(Version version) : this(new SemanticVersionImpl(version)) { } + /// Whether this is a pre-release version. + public bool IsPrerelease() + { + return !string.IsNullOrWhiteSpace(this.Build); + } + /// Get an integer indicating whether this version precedes (less than 0), supercedes (more than 0), or is equivalent to (0) the specified version. /// The version to compare with this instance. /// The value is null. -- cgit