Skip to content

Commit 0e68314

Browse files
committed
refactor(GitVersion.Configuration, GitVersion.Core): do not enclose JsonPropertyDefaultAttribute values in quotes
1 parent a2e8110 commit 0e68314

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/GitVersion.Configuration/GitVersionConfiguration.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ internal sealed record GitVersionConfiguration : BranchConfiguration, IGitVersio
4747

4848
[JsonPropertyName("tag-prefix")]
4949
[JsonPropertyDescription($"A regular expression which is used to trim Git tags before processing. Defaults to '{DefaultTagPrefix}'")]
50-
[JsonPropertyDefault(DefaultTagPrefix, true)]
50+
[JsonPropertyDefault(DefaultTagPrefix)]
5151
public string? TagPrefix { get; internal set; }
5252

5353
[JsonPropertyName("version-in-branch-pattern")]
5454
[JsonPropertyDescription($"A regular expression which is used to determine the version number in the branch name or commit message (e.g., v1.0.0-LTS). Defaults to '{DefaultVersionInBranchPattern}'.")]
55-
[JsonPropertyDefault(DefaultVersionInBranchPattern, true)]
55+
[JsonPropertyDefault(DefaultVersionInBranchPattern)]
5656
public string? VersionInBranchPattern { get; internal set; }
5757

5858
[JsonIgnore]
@@ -80,22 +80,22 @@ public string? NextVersion
8080

8181
[JsonPropertyName("major-version-bump-message")]
8282
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a major version increment. Defaults to '{IncrementStrategyFinder.DefaultMajorPattern}'")]
83-
[JsonPropertyDefault(IncrementStrategyFinder.DefaultMajorPattern, true)]
83+
[JsonPropertyDefault(IncrementStrategyFinder.DefaultMajorPattern)]
8484
public string? MajorVersionBumpMessage { get; internal set; } = IncrementStrategyFinder.DefaultMajorPattern;
8585

8686
[JsonPropertyName("minor-version-bump-message")]
8787
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a minor version increment. Defaults to '{IncrementStrategyFinder.DefaultMinorPattern}'")]
88-
[JsonPropertyDefault(IncrementStrategyFinder.DefaultMinorPattern, true)]
88+
[JsonPropertyDefault(IncrementStrategyFinder.DefaultMinorPattern)]
8989
public string? MinorVersionBumpMessage { get; internal set; } = IncrementStrategyFinder.DefaultMinorPattern;
9090

9191
[JsonPropertyName("patch-version-bump-message")]
9292
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a patch version increment. Defaults to '{IncrementStrategyFinder.DefaultPatchPattern}'")]
93-
[JsonPropertyDefault(IncrementStrategyFinder.DefaultPatchPattern, true)]
93+
[JsonPropertyDefault(IncrementStrategyFinder.DefaultPatchPattern)]
9494
public string? PatchVersionBumpMessage { get; internal set; } = IncrementStrategyFinder.DefaultPatchPattern;
9595

9696
[JsonPropertyName("no-bump-message")]
9797
[JsonPropertyDescription($"Used to tell GitVersion not to increment when in Mainline development mode. Defaults to '{IncrementStrategyFinder.DefaultNoBumpPattern}'")]
98-
[JsonPropertyDefault(IncrementStrategyFinder.DefaultNoBumpPattern, true)]
98+
[JsonPropertyDefault(IncrementStrategyFinder.DefaultNoBumpPattern)]
9999
public string? NoBumpMessage { get; internal set; } = IncrementStrategyFinder.DefaultNoBumpPattern;
100100

101101
[JsonPropertyName("tag-pre-release-weight")]
@@ -104,7 +104,7 @@ public string? NextVersion
104104

105105
[JsonPropertyName("commit-date-format")]
106106
[JsonPropertyDescription($"The format to use when calculating the commit date. Defaults to '{DefaultCommitDateFormat}'. See [Standard Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) and [Custom Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).")]
107-
[JsonPropertyDefault(DefaultCommitDateFormat, true)]
107+
[JsonPropertyDefault(DefaultCommitDateFormat)]
108108
#if NET7_0_OR_GREATER
109109
[System.Diagnostics.CodeAnalysis.StringSyntax("DateTimeFormat")] // See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute, https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute.datetimeformat?view=net-7.0#system-diagnostics-codeanalysis-stringsyntaxattribute-datetimeformat
110110
#endif

src/GitVersion.Core/Core/Attributes/JsonPropertyDefaultAttribute.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@ public sealed class JsonPropertyDefaultAttribute : JsonAttribute
1212
public JsonPropertyDefaultAttribute(string? value) => Value = value ?? "null";
1313

1414
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string)"/>
15-
/// <param name="value"><inheritdoc cref="JsonPropertyDefaultAttribute(string)" path="param[@name='value']"/></param>
16-
/// <param name="enclose">If <see langword="true"/>, the default value is enclosed with single-quotes, strongly implying the value is a <c>string-type</c>.</param>
17-
public JsonPropertyDefaultAttribute(string value, bool enclose) : this(enclose ? $"'{value}'" : $"{value}") { }
18-
19-
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string,bool)"/>
2015
public JsonPropertyDefaultAttribute(bool value) : this(value ? "true" : "false") { }
2116

22-
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string,bool)"/>
23-
/// <remarks>The Enum value is converted to string-preferring the symbol name over the numeral if possible--and the resulting string is enclosed with single-quotes.</remarks>
24-
public JsonPropertyDefaultAttribute(SemanticVersionFormat value) : this(value.ToString(), true) { }
17+
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string)"/>
18+
/// <remarks>The Enum value is converted to string, preferring the symbol name over the numeral if possible.</remarks>
19+
public JsonPropertyDefaultAttribute(SemanticVersionFormat value) : this(value.ToString()) { }
2520
/// <inheritdoc cref="JsonPropertyDefaultAttribute(SemanticVersionFormat)"/>
26-
public JsonPropertyDefaultAttribute(AssemblyVersioningScheme value) : this(value.ToString(), true) { }
21+
public JsonPropertyDefaultAttribute(AssemblyVersioningScheme value) : this(value.ToString()) { }
2722
/// <inheritdoc cref="JsonPropertyDefaultAttribute(SemanticVersionFormat)"/>
28-
public JsonPropertyDefaultAttribute(AssemblyFileVersioningScheme value) : this(value.ToString(), true) { }
23+
public JsonPropertyDefaultAttribute(AssemblyFileVersioningScheme value) : this(value.ToString()) { }
2924

30-
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string, bool)"/>
25+
/// <inheritdoc cref="JsonPropertyDefaultAttribute(string)"/>
3126
/// <remarks>Depending on the Type of the boxed value, the resulting string will be automatically enclosed with single-quotes. If the boxed value is NOT a string and is converted to a string from a numeric , object, array, boolean, or null-only type, then it will NOT be enclosed with single-quotes.</remarks>
3227
public JsonPropertyDefaultAttribute(object boxedValue)
3328
{

src/GitVersion.Core/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(
4747
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.Extensions.AssemblyVersioningScheme value) -> void
4848
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(GitVersion.SemanticVersionFormat value) -> void
4949
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(object! boxedValue) -> void
50-
GitVersion.Attributes.JsonPropertyDefaultAttribute.JsonPropertyDefaultAttribute(string! value, bool enclose) -> void
5150
GitVersion.Attributes.JsonPropertyDescriptionAttribute
5251
GitVersion.Attributes.JsonPropertyDescriptionAttribute.Description.get -> string!
5352
GitVersion.Attributes.JsonPropertyDescriptionAttribute.JsonPropertyDescriptionAttribute(string! description) -> void

0 commit comments

Comments
 (0)