Skip to content

Commit 970c993

Browse files
committed
修改部分版本号格式对比失败的问题
1 parent e5e2442 commit 970c993

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/JiuLing.CommonLibs.UnitTests/VersionUtilsTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ public void CheckNeedUpdate3Test(string currentVersion, string newVersion, strin
4545
}
4646

4747
[TestMethod()]
48-
[DataRow("1.0.0", "1.0.2", "1.0.0", true, true)]
48+
[DataRow("1.0.0", "1.0.2", "1.0.0", false, true)]
4949
[DataRow("1.0.0", "1.0.2", "1.0.1", true, false)]
5050
[DataRow("1.0.0", "1.0.0", "1.0.0", false, true)]
51+
[DataRow("1.0.0", "1.0.0.0", "1.0.0", false, true)]
52+
[DataRow("1.1.0", "1.2.0.0", "1.1.0.0", false, true)]
53+
[DataRow("1.0.0", "1.2.0.0", "1.1.0.0", true, false)]
5154
public void CheckNeedUpdate4Test(string currentVersion, string newVersion, string minVersion, bool isNeedUpdate, bool isAllowUse)
5255
{
5356
var result = VersionUtils.CheckNeedUpdate(currentVersion, newVersion, minVersion);

src/JiuLing.CommonLibs/JiuLing.CommonLibs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageProjectUrl>https://github.com/JiuLing-zhang/JiuLing.CommonLibs</PackageProjectUrl>
88
<PackageIcon>nuget_icon.png</PackageIcon>
99
<PackageIconUrl />
10-
<Version>1.6.3</Version>
10+
<Version>1.6.4</Version>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
1313
<Copyright>Copyright (c) 2021 九零</Copyright>

src/JiuLing.CommonLibs/VersionUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public static bool CheckNeedUpdate(Version currentVersion, Version newVersion)
5959
/// <returns>返回(是否需要自动更新,当前版本是否允许使用)</returns>
6060
public static (bool IsNeedUpdate, bool IsAllowUse) CheckNeedUpdate(string currentVersion, string newVersion, string minVersion)
6161
{
62-
Version current = new Version(currentVersion);
63-
Version version = new Version(newVersion);
64-
Version min = new Version(minVersion);
62+
Version current = ToVersionWithBuild(currentVersion);
63+
Version version = ToVersionWithBuild(newVersion);
64+
Version min = ToVersionWithBuild(minVersion);
6565
return CheckNeedUpdate(current, version, min);
6666
}
6767

@@ -84,7 +84,7 @@ public static (bool IsNeedUpdate, bool IsAllowUse) CheckNeedUpdate(Version curre
8484
return (true, false);
8585
}
8686

87-
return (true, true);
87+
return (false, true);
8888
}
8989
}
9090
}

0 commit comments

Comments
 (0)