This commit is contained in:
Pilzinsel64
2025-12-09 09:33:29 +01:00
parent ce3be11e16
commit c2d13876f6
2 changed files with 25 additions and 5 deletions

View File

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

View File

@@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>annotations</Nullable> <Nullable>annotations</Nullable>
<Version>2.7.2</Version> <Version>2.7.3</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">