@@ -1162,19 +1162,34 @@ Use <xref:System.Text.Json.Serialization.ReferenceHandler.Preserve> to enable un
1162
1162
<summary >Gets or sets a value that indicates whether nullability annotations should be respected during serialization and deserialization.</summary >
1163
1163
<value >To be added.</value >
1164
1164
<remarks >
1165
- <para >Nullability annotations are resolved from the properties, fields and constructor parameters</para >
1166
- <para >that are used by the serializer. This includes annotations stemming from attributes such as</para >
1167
1165
<para >
1168
- <see cref =" T:System.Diagnostics.CodeAnalysis.NotNullAttribute" />, <see cref =" T:System.Diagnostics.CodeAnalysis.MaybeNullAttribute" />,</para >
1166
+ Configures the serializer to throw an exception when trying to serialize a <see langword =" null" /> value from a non-nullable property getter,
1167
+ or when deserializing a <see langword =" null" /> value into a non-nullable property setter or constructor parameter.
1168
+ Nullability annotations are resolved from the properties, fields, and constructor parameters
1169
+ that are used by the serializer. This includes annotations stemming from attributes such as
1170
+ <see cref =" T:System.Diagnostics.CodeAnalysis.NotNullAttribute" />, <see cref =" T:System.Diagnostics.CodeAnalysis.MaybeNullAttribute" />,
1171
+ <see cref =" T:System.Diagnostics.CodeAnalysis.AllowNullAttribute" /> and <see cref =" T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute" />.
1172
+ </para >
1169
1173
<para >
1170
- <see cref =" T:System.Diagnostics.CodeAnalysis.AllowNullAttribute" /> and <see cref =" T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute" />.</para >
1171
- <para >Due to restrictions in how nullable reference types are represented at run time,</para >
1172
- <para >this setting only governs nullability annotations of non-generic properties and fields.</para >
1173
- <para >It cannot be used to enforce nullability annotations of root-level types or generic parameters.</para >
1174
- <para >The default setting for this property can be toggled application-wide using the</para >
1175
- <para >"System.Text.Json.Serialization.RespectNullableAnnotationsDefault" feature switch.</para >
1174
+ Due to restrictions in how nullable reference types are represented at run time,
1175
+ this setting only governs nullability annotations of non-generic properties, fields, and constructor parameters.
1176
+ It cannot be used to enforce nullability annotations of root-level types, collection elements, or generic parameters.
1177
+ The default setting for this property can be toggled application-wide using the
1178
+ "System.Text.Json.Serialization.RespectNullableAnnotationsDefault" feature switch.
1179
+ </para >
1180
+ <para >
1181
+ Nullability validation functions independently of required-ness validation,
1182
+ that is to say the setting has no effect in scenarios where the payload is missing a required property.
1183
+ This can be configured independently using the <see langword =" required" /> keyword,
1184
+ the <see cref =" P:System.Text.Json.Serialization.JsonRequiredAttribute" /> attribute,
1185
+ or the <see cref =" P:System.Text.Json.JsonSerializerOptions.RespectRequiredConstructorParameters" /> property.
1186
+ </para >
1187
+ <para >
1188
+ It is recommended that new applications always set this property to <see langword =" true" />,
1189
+ in combination with the closely related <see cref =" P:System.Text.Json.JsonSerializerOptions.RespectRequiredConstructorParameters" /> property.
1190
+ </para >
1176
1191
</remarks >
1177
- <exception cref =" T:System.InvalidOperationException" >Thrown if this property is set after serialization or deserialization has occurred.</exception >
1192
+ <exception cref =" T:System.InvalidOperationException" >This property is set after serialization or deserialization has occurred.</exception >
1178
1193
</Docs >
1179
1194
</Member >
1180
1195
<Member MemberName =" RespectRequiredConstructorParameters" >
@@ -1196,12 +1211,19 @@ Use <xref:System.Text.Json.Serialization.ReferenceHandler.Preserve> to enable un
1196
1211
<summary >Gets or sets a value that indicates whether non-optional constructor parameters should be specified during deserialization.</summary >
1197
1212
<value >To be added.</value >
1198
1213
<remarks >
1199
- <para >For historical reasons constructor-based deserialization treats all constructor parameters as optional by default.</para >
1200
- <para >This flag allows users to toggle that behavior as necessary for each <see cref =" T:System.Text.Json.JsonSerializerOptions" /> instance.</para >
1201
- <para >The default setting for this property can be toggled application-wide using the</para >
1202
- <para >"System.Text.Json.Serialization.RespectRequiredConstructorParametersDefault" feature switch.</para >
1214
+ <para >
1215
+ For historical reasons constructor-based deserialization treats all constructor parameters as optional by default,
1216
+ filling missing parameters with default values when they are not present in the JSON payload.
1217
+ This flag allows users to toggle that behavior as necessary for each <see cref =" T:System.Text.Json.JsonSerializerOptions" /> instance.
1218
+ The default setting for this property can be toggled application-wide using the
1219
+ "System.Text.Json.Serialization.RespectRequiredConstructorParametersDefault" feature switch.
1220
+ </para >
1221
+ <para >
1222
+ It is recommended that new applications always set this property to <see langword =" true" />,
1223
+ in combination with the closely related <see cref =" P:System.Text.Json.JsonSerializerOptions.RespectNullableAnnotations" /> property.
1224
+ </para >
1203
1225
</remarks >
1204
- <exception cref =" T:System.InvalidOperationException" >Thrown if this property is set after serialization or deserialization has occurred.</exception >
1226
+ <exception cref =" T:System.InvalidOperationException" >This property is set after serialization or deserialization has occurred.</exception >
1205
1227
</Docs >
1206
1228
</Member >
1207
1229
<Member MemberName =" TryGetTypeInfo" >
0 commit comments