From eaa16d2ca18d8aa41ea081f1514d23ca7d820d87 Mon Sep 17 00:00:00 2001 From: ElektroKill Date: Fri, 12 Jan 2024 19:30:45 +0100 Subject: [PATCH] Update checker now correctly handles release candidate builds --- dnSpy/dnSpy/MainApp/UpdateService.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dnSpy/dnSpy/MainApp/UpdateService.cs b/dnSpy/dnSpy/MainApp/UpdateService.cs index 6215293e27..57b43e01ff 100644 --- a/dnSpy/dnSpy/MainApp/UpdateService.cs +++ b/dnSpy/dnSpy/MainApp/UpdateService.cs @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License using System.Diagnostics; using System.Net.Http; using System.Net.Http.Headers; +using System.Reflection; using System.Threading.Tasks; using dnSpy.Contracts.Settings; using Newtonsoft.Json.Linq; @@ -100,6 +101,7 @@ public UpdateService(ISettingsService settingsService) { } static readonly Version currentVersion = GetCurrentVersion(); + static readonly bool isFinalRelease = GetIsFinalRelease(); static Version GetCurrentVersion() { var currentAsm = typeof(StartUpClass).Assembly; @@ -113,10 +115,21 @@ static Version GetCurrentVersion() { return currentAsm.GetName().Version!; } + static bool GetIsFinalRelease() { + var currentAsm = typeof(StartUpClass).Assembly; + try { + var infoVerAttr = currentAsm.GetCustomAttribute(); + return infoVerAttr.InformationalVersion is null || !infoVerAttr.InformationalVersion.Contains("-"); + } + catch { + } + return false; + } + public async Task CheckForUpdatesAsync() { var updateInfo = await TryGetLatestVersionAsync(); if (updateInfo is not null) { - if (updateInfo.Value.Version > currentVersion) + if (updateInfo.Value.Version > currentVersion || !isFinalRelease && updateInfo.Value.Version == currentVersion) return new UpdateCheckInfo(true, updateInfo.Value); return new UpdateCheckInfo(false, default); } @@ -140,8 +153,11 @@ public async Task CheckForUpdatesAsync() { return null; if (tagName[0] == 'v') tagName = tagName.Remove(0, 1); - if (Version.TryParse(tagName, out var version)) + if (Version.TryParse(tagName, out var version)) { + if (version.Revision == -1) + version = new Version(version.Major, version.Minor, version.Build, 0); return new VersionInfo(version, htmlUrl); + } } catch { }