From 00389e5ee6a37e26bfc405529fc3c1a84b6d2175 Mon Sep 17 00:00:00 2001 From: Daniel Palme Date: Sat, 21 Dec 2024 20:40:18 +0100 Subject: [PATCH] #714 Improved AoT compatibility --- src/ReportGenerator.Core/Generator.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ReportGenerator.Core/Generator.cs b/src/ReportGenerator.Core/Generator.cs index 4ea89ae5..bcdfe15c 100644 --- a/src/ReportGenerator.Core/Generator.cs +++ b/src/ReportGenerator.Core/Generator.cs @@ -151,10 +151,18 @@ public bool GenerateReport( return false; } - Logger.Debug(Resources.Settings); - Logger.Debug(" " + System.Text.Json.JsonSerializer.Serialize(settings)); - Logger.Debug(" " + System.Text.Json.JsonSerializer.Serialize(minimumCoverageThresholds)); - Logger.Debug(" " + System.Text.Json.JsonSerializer.Serialize(riskHotspotsAnalysisThresholds)); + try + { + string settingsAsJson = System.Text.Json.JsonSerializer.Serialize(settings); + Logger.Debug(Resources.Settings); + Logger.Debug(" " + settingsAsJson); + Logger.Debug(" " + System.Text.Json.JsonSerializer.Serialize(minimumCoverageThresholds)); + Logger.Debug(" " + System.Text.Json.JsonSerializer.Serialize(riskHotspotsAnalysisThresholds)); + } + catch (InvalidOperationException) + { + // Json serialization may fail in AOT scenarios + } var stopWatch = Stopwatch.StartNew();