Skip to content

Commit a694480

Browse files
bergmeisterChristoph Bergmeister
and
Christoph Bergmeister
authored
Make CompatibilityCollector able to parse a single version String (#1446)
Co-authored-by: Christoph Bergmeister <christoph.bergmeister@bjss.com>
1 parent 1971035 commit a694480

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Common/PowerShellVersion.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public static PowerShellVersion Parse(string versionStr)
8888

8989
if (dotCount == 0)
9090
{
91-
throw new ArgumentException($"Version string '{versionStr}' must contain at least one dot separator");
91+
var majorVersion = int.Parse(versionStr);
92+
return new PowerShellVersion(majorVersion, -1, -1, label: null);
9293
}
9394

9495
versionParts[dotCount] = int.Parse(versionStr.Substring(sectionStartOffset, i - sectionStartOffset));

PSCompatibilityCollector/Tests/UtilityApi.Tests.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Describe "PowerShell version object" {
101101
Context "Version parsing" {
102102
BeforeAll {
103103
$genericVerCases = @(
104+
@{ VerStr = '42'; Major = 42; Minor = -1; Patch = -1 }
105+
@{ VerStr = '7'; Major = 7; Minor = -1; Patch = -1 }
104106
@{ VerStr = '6.1'; Major = 6; Minor = 1; Patch = -1 }
105107
@{ VerStr = '5.2.7'; Major = 5; Minor = 2; Patch = 7 }
106108
@{ VerStr = '512.2124.71'; Major = 512; Minor = 2124; Patch = 71 }

0 commit comments

Comments
 (0)