Skip to content

Commit

Permalink
Make CompatibilityCollector able to parse a single version String (#1446
Browse files Browse the repository at this point in the history
)

Co-authored-by: Christoph Bergmeister <christoph.bergmeister@bjss.com>
  • Loading branch information
bergmeister and Christoph Bergmeister authored Apr 17, 2020
1 parent 1971035 commit a694480
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static PowerShellVersion Parse(string versionStr)

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

versionParts[dotCount] = int.Parse(versionStr.Substring(sectionStartOffset, i - sectionStartOffset));
Expand Down
2 changes: 2 additions & 0 deletions PSCompatibilityCollector/Tests/UtilityApi.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Describe "PowerShell version object" {
Context "Version parsing" {
BeforeAll {
$genericVerCases = @(
@{ VerStr = '42'; Major = 42; Minor = -1; Patch = -1 }
@{ VerStr = '7'; Major = 7; Minor = -1; Patch = -1 }
@{ VerStr = '6.1'; Major = 6; Minor = 1; Patch = -1 }
@{ VerStr = '5.2.7'; Major = 5; Minor = 2; Patch = 7 }
@{ VerStr = '512.2124.71'; Major = 512; Minor = 2124; Patch = 71 }
Expand Down

0 comments on commit a694480

Please sign in to comment.