Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/PSVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,11 @@ public SemanticVersion(int major) : this(major, 0, 0) {}
/// <param name="version">The version.</param>
public SemanticVersion(Version version)
{
if (version.Revision > 0 || version.Build < 0) throw PSTraceSource.NewArgumentException(nameof(version));
if (version.Revision > 0) throw PSTraceSource.NewArgumentException(nameof(version));

Major = version.Major;
Minor = version.Minor;
Patch = version.Build;
Patch = version.Build == -1 ? 0 : version.Build;
var psobj = new PSObject(version);
var labelNote = psobj.Properties[LabelPropertyName];
if (labelNote != null)
Expand Down
3 changes: 3 additions & 0 deletions test/powershell/engine/SemanticVersion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Describe "SemanticVersion api tests" -Tags 'CI' {
}

It "version arg constructor" {
$v = [SemanticVersion]::new([Version]::new(1, 2))
$v.ToString() | Should Be '1.2.0'

$v = [SemanticVersion]::new([Version]::new(1, 2, 3))
$v.ToString() | Should Be '1.2.3'
}
Expand Down