improve
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'">
|
||||
|
||||
Reference in New Issue
Block a user