diff --git a/xml/System.Text.Json/JsonSerializerOptions.xml b/xml/System.Text.Json/JsonSerializerOptions.xml index 0ea4a3be74a..e6be2736252 100644 --- a/xml/System.Text.Json/JsonSerializerOptions.xml +++ b/xml/System.Text.Json/JsonSerializerOptions.xml @@ -1162,19 +1162,34 @@ Use to enable un Gets or sets a value that indicates whether nullability annotations should be respected during serialization and deserialization. To be added. - Nullability annotations are resolved from the properties, fields and constructor parameters - that are used by the serializer. This includes annotations stemming from attributes such as - , , + Configures the serializer to throw an exception when trying to serialize a value from a non-nullable property getter, + or when deserializing a value into a non-nullable property setter or constructor parameter. + Nullability annotations are resolved from the properties, fields, and constructor parameters + that are used by the serializer. This includes annotations stemming from attributes such as + , , + and . + - and . - Due to restrictions in how nullable reference types are represented at run time, - this setting only governs nullability annotations of non-generic properties and fields. - It cannot be used to enforce nullability annotations of root-level types or generic parameters. - The default setting for this property can be toggled application-wide using the - "System.Text.Json.Serialization.RespectNullableAnnotationsDefault" feature switch. + Due to restrictions in how nullable reference types are represented at run time, + this setting only governs nullability annotations of non-generic properties, fields, and constructor parameters. + It cannot be used to enforce nullability annotations of root-level types, collection elements, or generic parameters. + The default setting for this property can be toggled application-wide using the + "System.Text.Json.Serialization.RespectNullableAnnotationsDefault" feature switch. + + + Nullability validation functions independently of required-ness validation, + that is to say the setting has no effect in scenarios where the payload is missing a required property. + This can be configured independently using the keyword, + the attribute, + or the property. + + + It is recommended that new applications always set this property to , + in combination with the closely related property. + - Thrown if this property is set after serialization or deserialization has occurred. + This property is set after serialization or deserialization has occurred. @@ -1196,12 +1211,19 @@ Use to enable un Gets or sets a value that indicates whether non-optional constructor parameters should be specified during deserialization. To be added. - For historical reasons constructor-based deserialization treats all constructor parameters as optional by default. - This flag allows users to toggle that behavior as necessary for each instance. - The default setting for this property can be toggled application-wide using the - "System.Text.Json.Serialization.RespectRequiredConstructorParametersDefault" feature switch. + + For historical reasons constructor-based deserialization treats all constructor parameters as optional by default, + filling missing parameters with default values when they are not present in the JSON payload. + This flag allows users to toggle that behavior as necessary for each instance. + The default setting for this property can be toggled application-wide using the + "System.Text.Json.Serialization.RespectRequiredConstructorParametersDefault" feature switch. + + + It is recommended that new applications always set this property to , + in combination with the closely related property. + - Thrown if this property is set after serialization or deserialization has occurred. + This property is set after serialization or deserialization has occurred.