diff --git a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/RemoteInstanceConverter.cs b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/RemoteInstanceConverter.cs index 412dd11723..535d47a61f 100644 --- a/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/RemoteInstanceConverter.cs +++ b/src/ServiceControlInstaller.Engine/Configuration/ServiceControl/RemoteInstanceConverter.cs @@ -6,17 +6,15 @@ public static class RemoteInstanceConverter { - public static List FromJson(string json) => JsonSerializer.Deserialize>(json, Options); + public static List FromJson(string json) => JsonSerializer.Deserialize(json, RemoteInstanceContext.Default.ListRemoteInstanceSetting); - public static string ToJson(IList settings) => JsonSerializer.Serialize(settings, Options); - - static readonly JsonSerializerOptions Options = new() - { - WriteIndented = false, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull - }; + public static string ToJson(List settings) => JsonSerializer.Serialize(settings, RemoteInstanceContext.Default.ListRemoteInstanceSetting); } + [JsonSourceGenerationOptions(WriteIndented = false, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] + [JsonSerializable(typeof(List))] + public partial class RemoteInstanceContext : JsonSerializerContext; + public class RemoteInstanceSetting { [JsonPropertyName("api_uri")] diff --git a/src/ServiceControlInstaller.Engine/Unattended/UnattendAuditInstaller.cs b/src/ServiceControlInstaller.Engine/Unattended/UnattendAuditInstaller.cs index 7d7eca55c2..eb80879cdb 100644 --- a/src/ServiceControlInstaller.Engine/Unattended/UnattendAuditInstaller.cs +++ b/src/ServiceControlInstaller.Engine/Unattended/UnattendAuditInstaller.cs @@ -70,7 +70,7 @@ public async Task Add(ServiceControlAuditNewInstance details, Func Add(MonitoringNewInstance details, Func Update(MonitoringInstance instance, bool startService) } catch (Exception ex) { - logger.Error("Update failed: {0}", ex.Message); + logger.Error("Update failed: {0}", ex); return false; } diff --git a/src/ServiceControlInstaller.Engine/Unattended/UnattendServiceControlInstaller.cs b/src/ServiceControlInstaller.Engine/Unattended/UnattendServiceControlInstaller.cs index e96b84ebb3..ff2fc16964 100644 --- a/src/ServiceControlInstaller.Engine/Unattended/UnattendServiceControlInstaller.cs +++ b/src/ServiceControlInstaller.Engine/Unattended/UnattendServiceControlInstaller.cs @@ -61,7 +61,7 @@ public async Task Add(ServiceControlNewInstance details, Func Update(ServiceControlInstance instance, bool startServ } catch (Exception ex) { - logger.Error("Update failed: {0}", ex.Message); + logger.Error("Update failed: {0}", ex); return false; } finally @@ -270,7 +270,7 @@ public bool AddRemoteInstance(ServiceControlInstance instance, string[] remoteIn } catch (Exception ex) { - logger.Error("Adding remote instances Failed: {0}", ex.Message); + logger.Error("Adding remote instances Failed: {0}", ex); return false; } finally @@ -310,7 +310,7 @@ public bool RemoveRemoteInstance(ServiceControlInstance instance, string[] remot } catch (Exception ex) { - logger.Error("Removing remote instances Failed: {0}", ex.Message); + logger.Error("Removing remote instances Failed: {0}", ex); return false; } finally