Skip to content

Fix null handling when calling custom JsonConverters - #2103

Merged
tomasherceg merged 1 commit into
mainfrom
serializer-fix-converter-HandleNull
Aug 28, 2026
Merged

Fix null handling when calling custom JsonConverters#2103
tomasherceg merged 1 commit into
mainfrom
serializer-fix-converter-HandleNull

Conversation

@exyi

@exyi exyi commented Aug 27, 2026

Copy link
Copy Markdown
Member

System.Text.Json converters have HandleNull property, which we should respect:

  • when false (default), both serialization and deserialization should handle null values before the converter is called. Conterintuitively this is the case even if converter is explicitely defined for Nullable<...> type
  • when true: we don't check for null and let converter handle it

We always allow null in DotvvmConverters, because they all already handle it, and it keeps the generated code smaller.

System.Text.Json converters have HandleNull property,
which we should respect:
* when false (default), both serialization and deserialization should
  handle null values before the converter is called. Conterintuitively
  this is the case even if converter is explicitely defined for
  Nullable<...> type
* when true: we don't check for null and let converter handle it

We always allow null in DotvvmConverters, because they all already
handle it, and it keeps the generated code smaller.
@exyi
exyi force-pushed the serializer-fix-converter-HandleNull branch from 5aa6a32 to 4468757 Compare August 28, 2026 11:56
@tomasherceg
tomasherceg merged commit f66ad85 into main Aug 28, 2026
17 of 18 checks passed
@tomasherceg
tomasherceg deleted the serializer-fix-converter-HandleNull branch August 28, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants