Severity: Info / Code Quality
Files:
src/Servy.Core/Services/ServiceExporter.cs lines 69-76 and 84-102
src/Servy.Core/Services/JsonServiceSerializer.cs lines 44-60
Finding
The codebase has two parallel JSON-export paths for the same ServiceDto, and they configure Newtonsoft.Json differently, so the output for the same DTO is not byte-for-byte identical.
ServiceExporter.ExportJson(ServiceDto service):
return JsonConvert.SerializeObject(service, Newtonsoft.Json.Formatting.Indented,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
JsonServiceSerializer.Serialize(ServiceDto? dto):
return JsonConvert.SerializeObject(dto, Formatting.Indented, JsonSecurity.UntrustedDataSettings);
JsonSecurity.UntrustedDataSettings (src/Servy.Core/Security/JsonSecurity.cs):
public static readonly JsonSerializerSettings UntrustedDataSettings = new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.None,
MaxDepth = 32,
MetadataPropertyHandling = MetadataPropertyHandling.Ignore
};
The two settings objects do not overlap:
ServiceExporter omits null-valued properties (NullValueHandling.Ignore) — produces a smaller JSON file with only set fields.
JsonServiceSerializer emits all null-valued properties — produces a larger JSON file with explicit null everywhere.
Both paths are reachable from ServiceCommands (Servy and Servy.Manager) and from the CLI, so the same export operation can produce different files depending on which code path is used.
Why this matters
Suggested fix
Severity: Info / Code Quality
Files:
src/Servy.Core/Services/ServiceExporter.cslines 69-76 and 84-102src/Servy.Core/Services/JsonServiceSerializer.cslines 44-60Finding
The codebase has two parallel JSON-export paths for the same
ServiceDto, and they configureNewtonsoft.Jsondifferently, so the output for the same DTO is not byte-for-byte identical.ServiceExporter.ExportJson(ServiceDto service):JsonServiceSerializer.Serialize(ServiceDto? dto):JsonSecurity.UntrustedDataSettings(src/Servy.Core/Security/JsonSecurity.cs):The two settings objects do not overlap:
ServiceExporteromits null-valued properties (NullValueHandling.Ignore) — produces a smaller JSON file with only set fields.JsonServiceSerializeremits all null-valued properties — produces a larger JSON file with explicitnulleverywhere.Both paths are reachable from
ServiceCommands(Servy and Servy.Manager) and from the CLI, so the same export operation can produce different files depending on which code path is used.Why this matters
ServiceExporter.ExportJsonwill look different from one produced byJsonServiceSerializer.Serialize, even when the source DTO is byte-identical.ServiceExporter, while the repository wires up the injectedIJsonServiceSerializer.Suggested fix
JsonSecurity.UntrustedDataSettingsto addNullValueHandling = NullValueHandling.Ignore).JsonServiceSerializer.SerializeandServiceExporter.ExportJsonshare that single object.ServiceExporterintoIJsonServiceSerializer/IXmlServiceSerializerso there is only one export path (matches the direction implied by [Code Quality] ServiceRepository.ExportXmlAsync — bypasses injected IXmlServiceSerializer, asymmetric with ImportXmlAsync (parallel to #822) #968 and [Code Quality] ServiceCommands.ImportXmlConfigAsync/ImportJsonConfigAsync — instantiates serializers directly instead of using validators-style DI #832).