diff --git a/Pilz/AppVersion.cs b/Pilz/AppVersion.cs index 0456321..fc62e8b 100644 --- a/Pilz/AppVersion.cs +++ b/Pilz/AppVersion.cs @@ -6,6 +6,11 @@ namespace Pilz; [method: JsonConstructor] public class AppVersion(Version version, int build, AppChannel channel) : IComparable, IComparable { + // F i e l d s + + private bool hasBuild; + private bool hasChannel; + // P r o p e r t i e s [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))] @@ -30,10 +35,10 @@ public class AppVersion(Version version, int build, AppChannel channel) : ICompa { string version = Version.ToString(); - if (Channel != AppChannel.Stable || Build != 1) + if (Channel != AppChannel.Stable || hasChannel || Build != 1 || hasBuild) version += "-" + Channel.ToString().ToLowerInvariant(); - if (Build != 1) + if (Build != 1 || hasBuild) version += "." + Build; return version; @@ -169,15 +174,30 @@ public class AppVersion(Version version, int build, AppChannel channel) : ICompa throw new FormatException("Bad version format: " + versionStr); // Parse channel + bool hasChannel; if (!Enum.TryParse(channelStr, true, out AppChannel channel)) + { channel = AppChannel.Stable; + hasChannel = false; + } + else + hasChannel = true; // Parse build + bool hasBuild; if (!int.TryParse(buildStr, out var build)) + { build = 1; + hasBuild = false; + } + else + hasBuild = true; - // Return new appversin - return new AppVersion(version, build, channel); + // Build new appversin + var appversion = new AppVersion(version, build, channel); + appversion.hasChannel = hasChannel; + appversion.hasBuild = hasBuild; + return appversion; } // C o m p a r e diff --git a/Pilz/Pilz.csproj b/Pilz/Pilz.csproj index 243c0b1..7ed151d 100644 --- a/Pilz/Pilz.csproj +++ b/Pilz/Pilz.csproj @@ -5,7 +5,7 @@ latest enable annotations - 2.7.2 + 2.7.3