Skip to content

[Correctness] IJsonServiceSerializer vs IXmlServiceSerializer — Nullable parameter asymmetry #673

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

Files:

  • src/Servy.Core/Services/IJsonServiceSerializer.cs line 17
  • src/Servy.Core/Services/IXmlServiceSerializer.cs line 17

Description:
The two symmetric serializer interfaces are inconsistent: XML Deserialize accepts string? (null-safe), JSON Deserialize requires non-null string. A null JSON string will bypass the null contract at compile time and likely throw at runtime. Both should be string? since both can legitimately receive null.

Suggested fix:
Change IJsonServiceSerializer.Deserialize(string json) to Deserialize(string? json).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions