Skip to content

Commit 6fc1391

Browse files
committed
Add a const DefaultVersionPrecision
1 parent 150565a commit 6fc1391

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/NerdBank.GitVersioning/AssemblyVersionOptionsConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
4545
var data = value as VersionOptions.AssemblyVersionOptions;
4646
if (data != null)
4747
{
48-
if (data.Precision == VersionOptions.VersionPrecision.Minor)
48+
if (data.Precision == VersionOptions.DefaultVersionPrecision)
4949
{
5050
serializer.Serialize(writer, data.Version);
5151
return;

src/NerdBank.GitVersioning/VersionOptions.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public static VersionOptions FromVersion(Version version, string unstableTag = n
8787
};
8888
}
8989

90+
/// <summary>
91+
/// Default value for <see cref="VersionPrecision"/>.
92+
/// </summary>
93+
public const VersionPrecision DefaultVersionPrecision = VersionPrecision.Minor;
94+
9095
/// <summary>
9196
/// Checks equality against another object.
9297
/// </summary>
@@ -163,12 +168,12 @@ public AssemblyVersionOptions()
163168
/// </summary>
164169
/// <param name="version">The assembly version (with major.minor components).</param>
165170
/// <param name="precision">The additional version precision to add toward matching the AssemblyFileVersion.</param>
166-
public AssemblyVersionOptions(Version version, VersionPrecision precision = VersionPrecision.Minor)
171+
public AssemblyVersionOptions(Version version, VersionPrecision precision = DefaultVersionPrecision)
167172
{
168173
this.Version = version;
169174
this.Precision = precision;
170175
}
171-
176+
172177
/// <summary>
173178
/// Gets or sets the major.minor components of the assembly version.
174179
/// </summary>
@@ -179,8 +184,8 @@ public AssemblyVersionOptions(Version version, VersionPrecision precision = Vers
179184
/// Gets or sets the additional version precision to add toward matching the AssemblyFileVersion.
180185
/// </summary>
181186
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
182-
[DefaultValue(VersionPrecision.Minor)]
183-
public VersionPrecision Precision { get; set; } = VersionPrecision.Minor;
187+
[DefaultValue(DefaultVersionPrecision)]
188+
public VersionPrecision Precision { get; set; } = DefaultVersionPrecision;
184189

185190
/// <inheritdoc />
186191
public override bool Equals(object obj) => this.Equals(obj as AssemblyVersionOptions);

src/NerdBank.GitVersioning/VersionOracle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private static LibGit2Sharp.Repository OpenGitRepo(string repoRoot)
279279
private static Version GetAssemblyVersion(Version version, VersionOptions versionOptions)
280280
{
281281
var assemblyVersion = versionOptions?.AssemblyVersion?.Version ?? new System.Version(version.Major, version.Minor);
282-
var precision = versionOptions?.AssemblyVersion?.Precision ?? VersionOptions.VersionPrecision.Minor;
282+
var precision = versionOptions?.AssemblyVersion?.Precision ?? VersionOptions.DefaultVersionPrecision;
283283

284284
assemblyVersion = new System.Version(
285285
assemblyVersion.Major,

0 commit comments

Comments
 (0)