Skip to content

Commit b52a90d

Browse files
authored
Merge pull request #3806 from arturcic/feature/var-serialization
Refactor variable serialization and extend serialization tests
2 parents 848c4ed + bcd25ed commit b52a90d

File tree

19 files changed

+143
-91
lines changed

19 files changed

+143
-91
lines changed

src/GitVersion.App.Tests/GitVersion.App.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestStream.cs" Link="Helpers\TestStream.cs" />
2626
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestBase.cs" Link="Helpers\TestBase.cs" />
2727
<Compile Include="..\GitVersion.Core.Tests\Helpers\GitVersionCoreTestModule.cs" Link="Helpers\GitVersionCoreTestModule.cs" />
28+
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitVersionVariablesExtensions.cs" Link="Extensions\GitVersionVariablesExtensions.cs" />
2829
</ItemGroup>
2930

3031
</Project>

src/GitVersion.App.Tests/Helpers/ExecutionResults.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GitVersion.Core.Tests;
12
using GitVersion.OutputVariables;
23

34
namespace GitVersion.App.Tests;
@@ -23,7 +24,7 @@ public virtual GitVersionVariables OutputVariables
2324
var jsonEndIndex = Output.IndexOf('}');
2425
var json = Output.Substring(jsonStartIndex, jsonEndIndex - jsonStartIndex + 1);
2526

26-
return VersionVariablesHelper.FromJson(json);
27+
return json.ToGitVersionVariables();
2728
}
2829
}
2930
}

src/GitVersion.App.Tests/Helpers/ProgramFixture.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GitVersion.Core.Tests;
12
using GitVersion.Core.Tests.Helpers;
23
using GitVersion.Extensions;
34
using GitVersion.Logging;
@@ -86,11 +87,11 @@ public GitVersionVariables? OutputVariables
8687
{
8788
if (Output.IsNullOrWhiteSpace()) return null;
8889

89-
var jsonStartIndex = Output.IndexOf("{", StringComparison.Ordinal);
90-
var jsonEndIndex = Output.IndexOf("}", StringComparison.Ordinal);
90+
var jsonStartIndex = Output.IndexOf('{');
91+
var jsonEndIndex = Output.IndexOf('}');
9192
var json = Output.Substring(jsonStartIndex, jsonEndIndex - jsonStartIndex + 1);
9293

93-
return VersionVariablesHelper.FromJson(json);
94+
return json.ToGitVersionVariables();
9495
}
9596
}
9697
}

src/GitVersion.App.Tests/JsonOutputOnBuildServerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using GitVersion.Agents;
2+
using GitVersion.Core.Tests;
23
using GitVersion.Helpers;
3-
using GitVersion.OutputVariables;
44

55
namespace GitVersion.App.Tests;
66

@@ -61,7 +61,7 @@ public void BeingOnBuildServerWithOutputJsonAndOutputFileDoesNotFail(string outp
6161
var filePath = PathHelper.Combine(fixture.LocalRepositoryFixture.RepositoryPath, fileName);
6262
var json = File.ReadAllText(filePath);
6363

64-
var outputVariables = VersionVariablesHelper.FromJson(json);
64+
var outputVariables = json.ToGitVersionVariables();
6565
outputVariables.ShouldNotBeNull();
6666
outputVariables.FullSemVer.ShouldBeEquivalentTo(expectedVersion);
6767
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using GitVersion.OutputVariables;
2+
3+
namespace GitVersion.Core.Tests;
4+
5+
public static class GitVersionVariablesExtensions
6+
{
7+
public static string ToJson(this GitVersionVariables gitVersionVariables)
8+
{
9+
var serializer = new VersionVariableSerializer(new FileSystem());
10+
return serializer.ToJson(gitVersionVariables);
11+
}
12+
13+
public static GitVersionVariables ToGitVersionVariables(this string json)
14+
{
15+
var serializer = new VersionVariableSerializer(new FileSystem());
16+
return serializer.FromJson(json);
17+
}
18+
}

src/GitVersion.Core.Tests/VersionCalculation/JsonVersionBuilderTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using GitVersion.Core.Tests.Helpers;
2-
using GitVersion.OutputVariables;
32
using GitVersion.VersionCalculation;
43
using Microsoft.Extensions.DependencyInjection;
54

src/GitVersion.Core.Tests/VersionCalculation/VariableProviderTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GitVersion.Configuration;
22
using GitVersion.Core.Tests.Helpers;
33
using GitVersion.Logging;
4-
using GitVersion.OutputVariables;
54
using GitVersion.VersionCalculation;
65
using Microsoft.Extensions.DependencyInjection;
76

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace GitVersion.OutputVariables;
2+
3+
public interface IVersionVariableSerializer
4+
{
5+
GitVersionVariables FromJson(string json);
6+
string ToJson(GitVersionVariables gitVersionVariables);
7+
GitVersionVariables FromFile(string filePath);
8+
void ToFile(GitVersionVariables gitVersionVariables, string filePath);
9+
}

src/GitVersion.Core/PublicAPI.Unshipped.txt

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -492,61 +492,11 @@ GitVersion.OutputVariables.GitVersionVariables.VersionSourceSha.get -> string?
492492
GitVersion.OutputVariables.GitVersionVariables.VersionSourceSha.init -> void
493493
GitVersion.OutputVariables.GitVersionVariables.WeightedPreReleaseNumber.get -> string!
494494
GitVersion.OutputVariables.GitVersionVariables.WeightedPreReleaseNumber.init -> void
495-
GitVersion.OutputVariables.VersionVariablesHelper
496-
GitVersion.OutputVariables.VersionVariablesJsonModel
497-
GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemFileVer.get -> string?
498-
GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemFileVer.set -> void
499-
GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemVer.get -> string?
500-
GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemVer.set -> void
501-
GitVersion.OutputVariables.VersionVariablesJsonModel.BranchName.get -> string?
502-
GitVersion.OutputVariables.VersionVariablesJsonModel.BranchName.set -> void
503-
GitVersion.OutputVariables.VersionVariablesJsonModel.BuildMetaData.get -> int?
504-
GitVersion.OutputVariables.VersionVariablesJsonModel.BuildMetaData.set -> void
505-
GitVersion.OutputVariables.VersionVariablesJsonModel.CommitDate.get -> string?
506-
GitVersion.OutputVariables.VersionVariablesJsonModel.CommitDate.set -> void
507-
GitVersion.OutputVariables.VersionVariablesJsonModel.CommitsSinceVersionSource.get -> int?
508-
GitVersion.OutputVariables.VersionVariablesJsonModel.CommitsSinceVersionSource.set -> void
509-
GitVersion.OutputVariables.VersionVariablesJsonModel.EscapedBranchName.get -> string?
510-
GitVersion.OutputVariables.VersionVariablesJsonModel.EscapedBranchName.set -> void
511-
GitVersion.OutputVariables.VersionVariablesJsonModel.FullBuildMetaData.get -> string?
512-
GitVersion.OutputVariables.VersionVariablesJsonModel.FullBuildMetaData.set -> void
513-
GitVersion.OutputVariables.VersionVariablesJsonModel.FullSemVer.get -> string?
514-
GitVersion.OutputVariables.VersionVariablesJsonModel.FullSemVer.set -> void
515-
GitVersion.OutputVariables.VersionVariablesJsonModel.InformationalVersion.get -> string?
516-
GitVersion.OutputVariables.VersionVariablesJsonModel.InformationalVersion.set -> void
517-
GitVersion.OutputVariables.VersionVariablesJsonModel.Major.get -> int?
518-
GitVersion.OutputVariables.VersionVariablesJsonModel.Major.set -> void
519-
GitVersion.OutputVariables.VersionVariablesJsonModel.MajorMinorPatch.get -> string?
520-
GitVersion.OutputVariables.VersionVariablesJsonModel.MajorMinorPatch.set -> void
521-
GitVersion.OutputVariables.VersionVariablesJsonModel.Minor.get -> int?
522-
GitVersion.OutputVariables.VersionVariablesJsonModel.Minor.set -> void
523-
GitVersion.OutputVariables.VersionVariablesJsonModel.Patch.get -> int?
524-
GitVersion.OutputVariables.VersionVariablesJsonModel.Patch.set -> void
525-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseLabel.get -> string?
526-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseLabel.set -> void
527-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseLabelWithDash.get -> string?
528-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseLabelWithDash.set -> void
529-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseNumber.get -> int?
530-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseNumber.set -> void
531-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseTag.get -> string?
532-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseTag.set -> void
533-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseTagWithDash.get -> string?
534-
GitVersion.OutputVariables.VersionVariablesJsonModel.PreReleaseTagWithDash.set -> void
535-
GitVersion.OutputVariables.VersionVariablesJsonModel.SemVer.get -> string?
536-
GitVersion.OutputVariables.VersionVariablesJsonModel.SemVer.set -> void
537-
GitVersion.OutputVariables.VersionVariablesJsonModel.Sha.get -> string?
538-
GitVersion.OutputVariables.VersionVariablesJsonModel.Sha.set -> void
539-
GitVersion.OutputVariables.VersionVariablesJsonModel.ShortSha.get -> string?
540-
GitVersion.OutputVariables.VersionVariablesJsonModel.ShortSha.set -> void
541-
GitVersion.OutputVariables.VersionVariablesJsonModel.UncommittedChanges.get -> int?
542-
GitVersion.OutputVariables.VersionVariablesJsonModel.UncommittedChanges.set -> void
543-
GitVersion.OutputVariables.VersionVariablesJsonModel.VersionSourceSha.get -> string?
544-
GitVersion.OutputVariables.VersionVariablesJsonModel.VersionSourceSha.set -> void
545-
GitVersion.OutputVariables.VersionVariablesJsonModel.VersionVariablesJsonModel() -> void
546-
GitVersion.OutputVariables.VersionVariablesJsonModel.WeightedPreReleaseNumber.get -> int?
547-
GitVersion.OutputVariables.VersionVariablesJsonModel.WeightedPreReleaseNumber.set -> void
548-
GitVersion.OutputVariables.VersionVariablesJsonStringConverter
549-
GitVersion.OutputVariables.VersionVariablesJsonStringConverter.VersionVariablesJsonStringConverter() -> void
495+
GitVersion.OutputVariables.IVersionVariableSerializer
496+
GitVersion.OutputVariables.IVersionVariableSerializer.FromFile(string! filePath) -> GitVersion.OutputVariables.GitVersionVariables!
497+
GitVersion.OutputVariables.IVersionVariableSerializer.FromJson(string! json) -> GitVersion.OutputVariables.GitVersionVariables!
498+
GitVersion.OutputVariables.IVersionVariableSerializer.ToFile(GitVersion.OutputVariables.GitVersionVariables! gitVersionVariables, string! filePath) -> void
499+
GitVersion.OutputVariables.IVersionVariableSerializer.ToJson(GitVersion.OutputVariables.GitVersionVariables! gitVersionVariables) -> string!
550500
GitVersion.ReferenceName.TryGetSemanticVersion(out (GitVersion.SemanticVersion! Value, string? Name) result, System.Text.RegularExpressions.Regex! versionPatternRegex, string? tagPrefix, GitVersion.SemanticVersionFormat format) -> bool
551501
GitVersion.RefSpecDirection
552502
GitVersion.RefSpecDirection.Fetch = 0 -> GitVersion.RefSpecDirection
@@ -688,7 +638,7 @@ GitVersion.VersionCalculation.BaseVersion.ShouldIncrement.init -> void
688638
GitVersion.VersionCalculation.BaseVersion.Source.get -> string!
689639
GitVersion.VersionCalculation.BaseVersion.Source.init -> void
690640
GitVersion.VersionCalculation.Caching.GitVersionCache
691-
GitVersion.VersionCalculation.Caching.GitVersionCache.GitVersionCache(GitVersion.IFileSystem! fileSystem, GitVersion.Logging.ILog! log, GitVersion.IGitRepositoryInfo! repositoryInfo) -> void
641+
GitVersion.VersionCalculation.Caching.GitVersionCache.GitVersionCache(GitVersion.IFileSystem! fileSystem, GitVersion.OutputVariables.IVersionVariableSerializer! serializer, GitVersion.Logging.ILog! log, GitVersion.IGitRepositoryInfo! repositoryInfo) -> void
692642
GitVersion.VersionCalculation.Caching.GitVersionCache.LoadVersionVariablesFromDiskCache(GitVersion.VersionCalculation.Caching.GitVersionCacheKey! cacheKey) -> GitVersion.OutputVariables.GitVersionVariables?
693643
GitVersion.VersionCalculation.Caching.GitVersionCache.WriteVariablesToDiskCache(GitVersion.VersionCalculation.Caching.GitVersionCacheKey! cacheKey, GitVersion.OutputVariables.GitVersionVariables! versionVariables) -> void
694644
GitVersion.VersionCalculation.Caching.GitVersionCacheKey
@@ -765,10 +715,6 @@ override GitVersion.Agents.LocalBuild.IsDefault.get -> bool
765715
override GitVersion.BranchCommit.Equals(object? obj) -> bool
766716
override GitVersion.BranchCommit.GetHashCode() -> int
767717
override GitVersion.Helpers.LambdaKeyComparer<TSource, TKey>.Compare(TSource? x, TSource? y) -> int
768-
override GitVersion.OutputVariables.VersionVariablesJsonStringConverter.CanConvert(System.Type! typeToConvert) -> bool
769-
override GitVersion.OutputVariables.VersionVariablesJsonStringConverter.HandleNull.get -> bool
770-
override GitVersion.OutputVariables.VersionVariablesJsonStringConverter.Read(ref System.Text.Json.Utf8JsonReader reader, System.Type! typeToConvert, System.Text.Json.JsonSerializerOptions! options) -> string!
771-
override GitVersion.OutputVariables.VersionVariablesJsonStringConverter.Write(System.Text.Json.Utf8JsonWriter! writer, string? value, System.Text.Json.JsonSerializerOptions! options) -> void
772718
override GitVersion.ReferenceName.Equals(object? obj) -> bool
773719
override GitVersion.ReferenceName.GetHashCode() -> int
774720
override GitVersion.ReferenceName.ToString() -> string!
@@ -863,10 +809,6 @@ static GitVersion.Logging.LogExtensions.Warning(this GitVersion.Logging.ILog! lo
863809
static GitVersion.Logging.LogExtensions.Warning(this GitVersion.Logging.ILog! log, GitVersion.Logging.Verbosity verbosity, string! format, params object![]! args) -> void
864810
static GitVersion.Logging.LogExtensions.Warning(this GitVersion.Logging.ILog! log, string! format, params object![]! args) -> void
865811
static GitVersion.Logging.LogExtensions.Write(this GitVersion.Logging.ILog! log, GitVersion.Logging.LogLevel level, string! format, params object![]! args) -> void
866-
static GitVersion.OutputVariables.VersionVariablesHelper.FromFile(string! filePath, GitVersion.IFileSystem! fileSystem) -> GitVersion.OutputVariables.GitVersionVariables!
867-
static GitVersion.OutputVariables.VersionVariablesHelper.FromJson(string! json) -> GitVersion.OutputVariables.GitVersionVariables!
868-
static GitVersion.OutputVariables.VersionVariablesHelper.ToFile(GitVersion.OutputVariables.GitVersionVariables! gitVersionVariables, string! filePath, GitVersion.IFileSystem! fileSystem) -> void
869-
static GitVersion.OutputVariables.VersionVariablesHelper.ToJson(this GitVersion.OutputVariables.GitVersionVariables! gitVersionVariables) -> string!
870812
static GitVersion.ReferenceName.FromBranchName(string! branchName) -> GitVersion.ReferenceName!
871813
static GitVersion.ReferenceName.Parse(string! canonicalName) -> GitVersion.ReferenceName!
872814
static GitVersion.ReferenceName.TryParse(out GitVersion.ReferenceName? value, string! canonicalName) -> bool

src/GitVersion.Core/VersionCalculation/Caching/GitVersionCache.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ namespace GitVersion.VersionCalculation.Caching;
88
public class GitVersionCache : IGitVersionCache
99
{
1010
private readonly IFileSystem fileSystem;
11+
private readonly IVersionVariableSerializer serializer;
1112
private readonly ILog log;
1213
private readonly IGitRepositoryInfo repositoryInfo;
1314

14-
public GitVersionCache(IFileSystem fileSystem, ILog log, IGitRepositoryInfo repositoryInfo)
15+
public GitVersionCache(IFileSystem fileSystem, IVersionVariableSerializer serializer, ILog log, IGitRepositoryInfo repositoryInfo)
1516
{
1617
this.fileSystem = fileSystem.NotNull();
18+
this.serializer = serializer.NotNull();
1719
this.log = log.NotNull();
1820
this.repositoryInfo = repositoryInfo.NotNull();
1921
}
@@ -25,7 +27,7 @@ public void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, GitVersionVar
2527
{
2628
try
2729
{
28-
VersionVariablesHelper.ToFile(versionVariables, cacheFileName, this.fileSystem);
30+
serializer.ToFile(versionVariables, cacheFileName);
2931
}
3032
catch (Exception ex)
3133
{
@@ -46,7 +48,7 @@ public void WriteVariablesToDiskCache(GitVersionCacheKey cacheKey, GitVersionVar
4648
}
4749
try
4850
{
49-
var loadedVariables = VersionVariablesHelper.FromFile(cacheFileName, this.fileSystem);
51+
var loadedVariables = serializer.FromFile(cacheFileName);
5052
return loadedVariables;
5153
}
5254
catch (Exception ex)

src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestLogAppender.cs" Link="Helpers\TestLogAppender.cs" />
2828
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestStream.cs" Link="Helpers\TestStream.cs" />
2929
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitToolsTestingExtensions.cs" Link="Extensions\GitToolsTestingExtensions.cs" />
30+
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitVersionVariablesExtensions.cs" Link="Extensions\GitVersionVariablesExtensions.cs" />
3031
</ItemGroup>
3132
</Project>

src/GitVersion.MsBuild/GitVersionTaskExecutor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ internal class GitVersionTaskExecutor : IGitVersionTaskExecutor
1111
{
1212
private readonly IFileSystem fileSystem;
1313
private readonly IGitVersionOutputTool gitVersionOutputTool;
14+
private readonly IVersionVariableSerializer serializer;
1415
private readonly IConfigurationProvider configurationProvider;
1516
private readonly IOptions<GitVersionOptions> options;
1617

1718
public GitVersionTaskExecutor(IFileSystem fileSystem, IGitVersionOutputTool gitVersionOutputTool,
18-
IConfigurationProvider configurationProvider, IOptions<GitVersionOptions> options)
19+
IVersionVariableSerializer serializer, IConfigurationProvider configurationProvider,
20+
IOptions<GitVersionOptions> options)
1921
{
2022
this.fileSystem = fileSystem.NotNull();
2123
this.gitVersionOutputTool = gitVersionOutputTool.NotNull();
24+
this.serializer = serializer.NotNull();
2225
this.configurationProvider = configurationProvider.NotNull();
2326
this.options = options.NotNull();
2427
}
@@ -104,7 +107,7 @@ public void WriteVersionInfoToBuildLog(WriteVersionInfoToBuildLog task)
104107

105108
private GitVersionVariables GitVersionVariables(GitVersionTaskBase task)
106109
{
107-
var versionVariables = VersionVariablesHelper.FromFile(task.VersionFile, this.fileSystem);
110+
var versionVariables = serializer.FromFile(task.VersionFile);
108111
return versionVariables;
109112
}
110113
}

src/GitVersion.Output/GitVersionOutputModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using GitVersion.Output.GitVersionInfo;
33
using GitVersion.Output.OutputGenerator;
44
using GitVersion.Output.WixUpdater;
5+
using GitVersion.OutputVariables;
56
using Microsoft.Extensions.DependencyInjection;
67

78
namespace GitVersion.Output;
@@ -12,6 +13,7 @@ public void RegisterTypes(IServiceCollection services)
1213
{
1314
services.AddSingleton<IGitVersionOutputTool, GitVersionOutputTool>();
1415
services.AddSingleton<IOutputGenerator, OutputGenerator.OutputGenerator>();
16+
services.AddSingleton<IVersionVariableSerializer, VersionVariableSerializer>();
1517
services.AddSingleton<IGitVersionInfoGenerator, GitVersionInfoGenerator>();
1618
services.AddSingleton<IWixVersionFileUpdater, WixVersionFileUpdater>();
1719
services.AddSingleton<IAssemblyInfoFileUpdater, AssemblyInfoFileUpdater>();

src/GitVersion.Output/OutputGenerator/OutputGenerator.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ internal sealed class OutputGenerator : IOutputGenerator
1515
{
1616
private readonly IConsole console;
1717
private readonly IFileSystem fileSystem;
18+
private readonly IVersionVariableSerializer serializer;
1819
private readonly IEnvironment environment;
1920
private readonly IOptions<GitVersionOptions> options;
2021
private readonly ICurrentBuildAgent buildAgent;
2122

22-
public OutputGenerator(ICurrentBuildAgent buildAgent, IConsole console, IFileSystem fileSystem, IEnvironment environment, IOptions<GitVersionOptions> options)
23+
public OutputGenerator(ICurrentBuildAgent buildAgent, IConsole console, IFileSystem fileSystem,
24+
IVersionVariableSerializer serializer, IEnvironment environment, IOptions<GitVersionOptions> options)
2325
{
2426
this.console = console.NotNull();
2527
this.fileSystem = fileSystem.NotNull();
28+
this.serializer = serializer.NotNull();
2629
this.environment = environment;
2730
this.options = options.NotNull();
2831
this.buildAgent = buildAgent.NotNull();
@@ -36,7 +39,7 @@ public void Execute(GitVersionVariables variables, OutputContext context)
3639
this.buildAgent.WriteIntegration(this.console.WriteLine, variables, context.UpdateBuildNumber ?? true);
3740
}
3841

39-
var json = variables.ToJson();
42+
var json = this.serializer.ToJson(variables);
4043
if (gitVersionOptions.Output.Contains(OutputType.File))
4144
{
4245
var retryOperation = new RetryAction<IOException>();
@@ -55,6 +58,7 @@ public void Execute(GitVersionVariables variables, OutputContext context)
5558
{
5659
throw new WarningException("Cannot specify both /showvariable and /format");
5760
}
61+
5862
if (gitVersionOptions.ShowVariable is not null)
5963
{
6064
if (!variables.TryGetValue(gitVersionOptions.ShowVariable, out var part))
@@ -65,6 +69,7 @@ public void Execute(GitVersionVariables variables, OutputContext context)
6569
this.console.WriteLine(part);
6670
return;
6771
}
72+
6873
if (gitVersionOptions.Format is not null)
6974
{
7075
var format = gitVersionOptions.Format;

0 commit comments

Comments
 (0)