The appropriate [SemanticVersion] constructor now accepts a [version] instance that has only major and minor components specified, in which case the patch component now defaults to 0.
This commit is contained in:
parent
96506f4cc1
commit
30b97a5d7c
|
@ -493,11 +493,11 @@ namespace System.Management.Automation
|
|||
/// <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)
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue