@@ -584,6 +584,7 @@ public class NuGetPackageVersionOptions : IEquatable<NuGetPackageVersionOptions>
584584 {
585585 isFrozen = true ,
586586 semVer = 1.0f ,
587+ precision = VersionPrecision . Build
587588 } ;
588589
589590 [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
@@ -592,6 +593,9 @@ public class NuGetPackageVersionOptions : IEquatable<NuGetPackageVersionOptions>
592593 [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
593594 private float ? semVer ;
594595
596+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
597+ private VersionPrecision ? precision ;
598+
595599 /// <summary>
596600 /// Initializes a new instance of the <see cref="NuGetPackageVersionOptions" /> class.
597601 /// </summary>
@@ -623,6 +627,22 @@ public float? SemVer
623627 [ JsonIgnore ]
624628 public float ? SemVerOrDefault => this . SemVer ?? DefaultInstance . SemVer ;
625629
630+ /// <summary>
631+ /// Gets or sets number of version components to include when generating the package version.
632+ /// </summary>
633+ [ JsonProperty ( DefaultValueHandling = DefaultValueHandling . Ignore ) ]
634+ public VersionPrecision ? Precision
635+ {
636+ get => this . precision ;
637+ set => this . SetIfNotReadOnly ( ref this . precision , value ) ;
638+ }
639+
640+ /// <summary>
641+ /// Gets the number of version components to include when generating the package version.
642+ /// </summary>
643+ [ JsonIgnore ]
644+ public VersionPrecision PrecisionOrDefault => this . Precision ?? DefaultInstance . Precision ! . Value ;
645+
626646 /// <summary>
627647 /// Gets a value indicating whether this instance rejects all attempts to mutate it.
628648 /// </summary>
@@ -679,13 +699,22 @@ public bool Equals(NuGetPackageVersionOptions? x, NuGetPackageVersionOptions? y)
679699 return false ;
680700 }
681701
682- return x . SemVerOrDefault == y . SemVerOrDefault ;
702+ return x . SemVerOrDefault == y . SemVerOrDefault &&
703+ x . PrecisionOrDefault == y . PrecisionOrDefault ;
683704 }
684705
685706 /// <inheritdoc />
686707 public int GetHashCode ( NuGetPackageVersionOptions ? obj )
687708 {
688- return obj ? . SemVerOrDefault . GetHashCode ( ) ?? 0 ;
709+ if ( obj is null )
710+ return 0 ;
711+
712+ unchecked
713+ {
714+ var hash = obj . SemVerOrDefault . GetHashCode ( ) * 397 ;
715+ hash ^= obj . PrecisionOrDefault . GetHashCode ( ) ;
716+ return hash ;
717+ }
689718 }
690719 }
691720 }
0 commit comments