From a777a4bfd5fe25dbeab82f5310f3fe66bc04a1e4 Mon Sep 17 00:00:00 2001 From: Mark Summerville Date: Fri, 19 Jan 2018 22:21:36 +0800 Subject: [PATCH] Bug fix to address #299 --- TVRename#/Forms/UpdateNotification.cs | 2 +- TVRename#/TVRename/TVDoc.cs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/TVRename#/Forms/UpdateNotification.cs b/TVRename#/Forms/UpdateNotification.cs index 996432711..eac1f22e0 100644 --- a/TVRename#/Forms/UpdateNotification.cs +++ b/TVRename#/Forms/UpdateNotification.cs @@ -18,7 +18,7 @@ public UpdateNotification(UpdateVersion update) this.newVersion = update; InitializeComponent(); this.tbReleaseNotes.Text = this.newVersion.ReleaseNotesText; - this.lblStatus.Text = $@"There is new version {update.VersionNumber}-{update.Prerelease} available since "+ update.ReleaseDate.ToLocalTime() + "."; + this.lblStatus.Text = $@"There is new version {update} available since {update.ReleaseDate.ToLocalTime()}."; //If this call is slow then we can put it in a new thread and update the control as it comes back from GH UpdateWithMarkdown(); diff --git a/TVRename#/TVRename/TVDoc.cs b/TVRename#/TVRename/TVDoc.cs index e96069174..d787ca7cf 100644 --- a/TVRename#/TVRename/TVDoc.cs +++ b/TVRename#/TVRename/TVDoc.cs @@ -3195,17 +3195,28 @@ public int CompareTo(object obj) if (this.VersionNumber.CompareTo(otherUpdateVersion.VersionNumber) != 0) return this.VersionNumber.CompareTo(otherUpdateVersion.VersionNumber); //We have the same version - now we have to get tricky and look at the extension (rc1, beta2 etc) + //if both have no extension then they are the same + if (string.IsNullOrWhiteSpace(this.Prerelease) && string.IsNullOrWhiteSpace(otherUpdateVersion.Prerelease)) return 0; //If either are not present then you can assume they are FINAL versions and trump any rx1 verisons - if (String.IsNullOrWhiteSpace( this.Prerelease) ) return 1; - if (String.IsNullOrWhiteSpace(otherUpdateVersion .Prerelease)) return -1; + if (string.IsNullOrWhiteSpace( this.Prerelease) ) return 1; + if (string.IsNullOrWhiteSpace(otherUpdateVersion .Prerelease)) return -1; //We have 2 suffixes //Compare alphabetically alpha1 < alpha2 < beta1 < beta2 < rc1 < rc2 etc - return (String.Compare(this.Prerelease , otherUpdateVersion.Prerelease , StringComparison.OrdinalIgnoreCase) ); + return (string.Compare(this.Prerelease , otherUpdateVersion.Prerelease , StringComparison.OrdinalIgnoreCase) ); } public bool NewerThan(UpdateVersion compare) => (CompareTo(compare) > 0); + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(this.VersionNumber); + if (!string.IsNullOrWhiteSpace(this.Prerelease)) sb.Append("-" + this.Prerelease); + if (!string.IsNullOrWhiteSpace(this.Build)) sb.Append("-(" + this.Build+")"); + return sb.ToString() ; + } }