diff --git a/gui/Process/ExecutableHelper.cs b/gui/Process/ExecutableHelper.cs index 3ae3b3f..41facaa 100644 --- a/gui/Process/ExecutableHelper.cs +++ b/gui/Process/ExecutableHelper.cs @@ -81,13 +81,13 @@ namespace com.muldersoft.slunkcrypt.gui.process executableFile = new FileStream(Path.Combine(appBaseDirectory, String.Format(FILENAME_FORMAT, suffix)), FileMode.Open, FileAccess.Read, FileShare.Read); try { - Version appVersion = VersionInfo.Version; FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(executableFile.Name); + Version appVersion = VersionInfo.Version; if (string.Equals(fileVersion.FileDescription, "SlunkCrypt", StringComparison.OrdinalIgnoreCase) && string.Equals(fileVersion.CompanyName, "Muldersoft", StringComparison.OrdinalIgnoreCase) && (fileVersion.FileMajorPart == appVersion.Major) && (fileVersion.FileMinorPart == appVersion.Minor)) { - success = true; + success = (fileVersion.FilePrivatePart >= appVersion.Revision); } } finally diff --git a/gui/Properties/AssemblyInfo.cs b/gui/Properties/AssemblyInfo.cs index 51a1876..19408d5 100644 --- a/gui/Properties/AssemblyInfo.cs +++ b/gui/Properties/AssemblyInfo.cs @@ -7,6 +7,8 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Windows; +using static com.muldersoft.slunkcrypt.gui.Properties._Version; + [assembly: AssemblyTitle("SlunkCrypt GUI")] [assembly: AssemblyDescription("SlunkCrypt GUI")] [assembly: AssemblyConfiguration("")] @@ -19,5 +21,6 @@ using System.Windows; [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("1.2.*")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion(VERS_MAJOR + "." + VERS_MINOR + ".*")] +[assembly: AssemblyFileVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)] +[assembly: AssemblyInformationalVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)] diff --git a/gui/Properties/_Version.cs b/gui/Properties/_Version.cs new file mode 100644 index 0000000..6d4c521 --- /dev/null +++ b/gui/Properties/_Version.cs @@ -0,0 +1,14 @@ +/******************************************************************************/ +/* SlunkCrypt, by LoRd_MuldeR */ +/* This work has been released under the CC0 1.0 Universal license! */ +/******************************************************************************/ + +namespace com.muldersoft.slunkcrypt.gui.Properties +{ + internal static class _Version + { + public const string VERS_MAJOR = "1"; + public const string VERS_MINOR = "2"; + public const string VERS_PATCH = "1"; + } +} diff --git a/gui/SlunkCryptGUI.csproj b/gui/SlunkCryptGUI.csproj index 05035fa..11c5a71 100644 --- a/gui/SlunkCryptGUI.csproj +++ b/gui/SlunkCryptGUI.csproj @@ -81,6 +81,7 @@ PasswordToggleBox.xaml + diff --git a/gui/SlunkCryptGUI.xaml.cs b/gui/SlunkCryptGUI.xaml.cs index cce47e4..4db8af5 100644 --- a/gui/SlunkCryptGUI.xaml.cs +++ b/gui/SlunkCryptGUI.xaml.cs @@ -852,7 +852,7 @@ namespace com.muldersoft.slunkcrypt.gui CPUFeatures cpuFeatures = CPUFeatures.Features; return new StringBuilder() .AppendLine("SlunkCrypt, by LoRd_MuldeR ") - .AppendLine(VersionInfo.VersionStr) + .AppendLine(VersionInfo.ToString()) .AppendLine("This work has been released under the \u201CCC0 1.0\u201D license!") .AppendLine() .AppendLine("Official web-site: http://slunkcrypt.osdn.io/") diff --git a/gui/Utilities/VersionInfo.cs b/gui/Utilities/VersionInfo.cs index f433a18..f000165 100644 --- a/gui/Utilities/VersionInfo.cs +++ b/gui/Utilities/VersionInfo.cs @@ -10,49 +10,60 @@ namespace com.muldersoft.slunkcrypt.gui.utils { static class VersionInfo { - private static readonly Lazy m_version = new Lazy(GetAssemblyVersion); - private static readonly Lazy m_versionStr = new Lazy(InitVersionString); + private static readonly Lazy m_version = new Lazy (InitializeVersion); + private static readonly Lazy m_buildDateTime = new Lazy(InitializeBuildDateTime); // ============================================================================= // Properties // ============================================================================= - public static Version Version - { - get { return m_version.Value; } - } + public static Version Version { get { return m_version.Value; } } - public static string VersionStr + public static DateTime BuildDate { get { return m_buildDateTime.Value; } } + + public static new string ToString() { - get { return m_versionStr.Value; } + Version version = m_version.Value; + return string.Format( + (version.Revision > 0) ? "Version {0:D}.{1:D}.{2:D}, built on {3}" : "Version {0:D}.{1:D}, built on {3}", + version.Major, version.Minor, version.Revision, BuildDate.ToString("yyyy-MM-dd")); } // ============================================================================= // Internal methods // ============================================================================= - private static Version GetAssemblyVersion() + private static Version InitializeVersion() { try { - return Assembly.GetExecutingAssembly().GetName().Version; + AssemblyFileVersionAttribute fileVersionAttribute = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyFileVersionAttribute), false) as AssemblyFileVersionAttribute; + Version fileVersion; + if (Version.TryParse(fileVersionAttribute?.Version, out fileVersion)) + { + return fileVersion; + } + else + { + return Assembly.GetExecutingAssembly().GetName().Version; + } } catch { - return new Version(); + return new Version(0, 0, 0, 0); } } - private static string InitVersionString() + private static DateTime InitializeBuildDateTime() { try { - DateTime buildDate = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * Version.Build + TimeSpan.TicksPerSecond * 2 * Version.Revision)); - return String.Format("Version {0:D}.{1:D}, built on {2}", Version.Major, Version.Minor, buildDate.ToString("yyyy-MM-dd")); + Version version = Assembly.GetExecutingAssembly().GetName().Version; + return new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); } catch { - return "Unknown version"; + return new DateTime(1928, 6, 14, 0, 0, 0, DateTimeKind.Utc); } } }