Skip to content

Commit 9f83926

Browse files
committed
Allow "major" as a value for assemblyVersion.precision
1 parent 3beb889 commit 9f83926

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
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 == default(VersionOptions.VersionPrecision))
48+
if (data.Precision == VersionOptions.VersionPrecision.Minor)
4949
{
5050
serializer.Serialize(writer, data.Version);
5151
return;

src/NerdBank.GitVersioning/VersionOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public AssemblyVersionOptions()
162162
/// </summary>
163163
/// <param name="version">The assembly version (with major.minor components).</param>
164164
/// <param name="precision">The additional version precision to add toward matching the AssemblyFileVersion.</param>
165-
public AssemblyVersionOptions(Version version, VersionPrecision precision = default(VersionPrecision))
165+
public AssemblyVersionOptions(Version version, VersionPrecision precision = VersionPrecision.Minor)
166166
{
167167
this.Version = version;
168168
this.Precision = precision;
@@ -368,6 +368,11 @@ public override int GetHashCode()
368368
/// </summary>
369369
public enum VersionPrecision
370370
{
371+
/// <summary>
372+
/// The first integer is the last number set. The rest will be zeros.
373+
/// </summary>
374+
Major,
375+
371376
/// <summary>
372377
/// The second integer is the last number set. The rest will be zeros.
373378
/// </summary>

src/NerdBank.GitVersioning/VersionOracle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private static Version GetAssemblyVersion(Version version, VersionOptions versio
281281
var assemblyVersion = versionOptions?.AssemblyVersion?.Version ?? new System.Version(version.Major, version.Minor);
282282
assemblyVersion = new System.Version(
283283
assemblyVersion.Major,
284-
assemblyVersion.Minor,
284+
versionOptions?.AssemblyVersion?.Precision >= VersionOptions.VersionPrecision.Minor ? version.Minor : 0,
285285
versionOptions?.AssemblyVersion?.Precision >= VersionOptions.VersionPrecision.Build ? version.Build : 0,
286286
versionOptions?.AssemblyVersion?.Precision >= VersionOptions.VersionPrecision.Revision ? version.Revision : 0);
287287
return assemblyVersion.EnsureNonNegativeComponents(4);

src/NerdBank.GitVersioning/version.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"precision": {
2121
"type": "string",
2222
"description": "Identifies the last component to be explicitly set in the version.",
23-
"enum": [ "minor", "build", "revision" ],
23+
"enum": [ "major", "minor", "build", "revision" ],
2424
"default": "minor"
2525
}
2626
}

0 commit comments

Comments
 (0)