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]
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
[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

View File

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