Skip to content

Commit 1a2be72

Browse files
authored
Changes.
1 parent 9090ad4 commit 1a2be72

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

SourceGenerator.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,21 @@ public void Execute(GeneratorExecutionContext context)
3030
return;
3131
}
3232

33-
GeneratorOptions? options = null;
3433
var gitBuildInfoJsonFile = context.AdditionalFiles
3534
.FirstOrDefault(af => string.Equals(Path.GetFileName(af.Path), "GitBuildInfo.json", StringComparison.OrdinalIgnoreCase));
36-
if (gitBuildInfoJsonFile is object)
35+
if (gitBuildInfoJsonFile is null)
3736
{
38-
var optionsJson = gitBuildInfoJsonFile.GetText(context.CancellationToken)!.ToString();
39-
options = JsonSerializer.Deserialize<GeneratorOptions>(optionsJson, new JsonSerializerOptions
37+
return;
38+
}
39+
40+
var options = JsonSerializer.Deserialize<GeneratorOptions>(
41+
gitBuildInfoJsonFile.GetText(context.CancellationToken)!.ToString(),
42+
new JsonSerializerOptions
4043
{
4144
AllowTrailingCommas = true,
4245
ReadCommentHandling = JsonCommentHandling.Skip,
4346
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
4447
});
45-
}
46-
47-
if (options is null || gitBuildInfoJsonFile is null)
48-
{
49-
return;
50-
}
51-
5248
if (string.IsNullOrEmpty(options.AssemblyType))
5349
{
5450
throw new GenerationFailedException("AssemblyType should not be null or an empty string.");

0 commit comments

Comments
 (0)