Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2b2dd51

Browse files
authored
Use named argument syntax for null values in json serialization methods (#40435)
1 parent a690f16 commit 2b2dd51

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public static ulong GetKey(ReadOnlySpan<byte> propertyName)
435435
public static Type GetElementType(Type propertyType, Type parentType, MemberInfo memberInfo, JsonSerializerOptions options)
436436
{
437437
// We want to handle as the implemented collection type, if applicable.
438-
Type implementedType = GetImplementedCollectionType(parentType, propertyType, null, out _, options);
438+
Type implementedType = GetImplementedCollectionType(parentType, propertyType, propertyInfo: null, out _, options);
439439

440440
if (!typeof(IEnumerable).IsAssignableFrom(implementedType))
441441
{
@@ -484,7 +484,7 @@ public static ClassType GetClassType(Type type, JsonSerializerOptions options)
484484
Debug.Assert(type != null);
485485

486486
// We want to handle as the implemented collection type, if applicable.
487-
Type implementedType = GetImplementedCollectionType(typeof(object), type, null, out _, options);
487+
Type implementedType = GetImplementedCollectionType(typeof(object), type, propertyInfo: null, out _, options);
488488

489489
if (implementedType.IsGenericType && implementedType.GetGenericTypeDefinition() == typeof(Nullable<>))
490490
{

src/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,14 @@ internal JsonPropertyInfo GetJsonPropertyInfoFromClassInfo(Type objectType, Json
355355
{
356356
if (!_objectJsonProperties.TryGetValue(objectType, out JsonPropertyInfo propertyInfo))
357357
{
358-
propertyInfo = JsonClassInfo.CreateProperty(objectType, objectType, objectType, null, typeof(object), null, options);
358+
propertyInfo = JsonClassInfo.CreateProperty(
359+
objectType,
360+
objectType,
361+
objectType,
362+
propertyInfo: null,
363+
typeof(object),
364+
converter: null,
365+
options);
359366
_objectJsonProperties[objectType] = propertyInfo;
360367
}
361368

0 commit comments

Comments
 (0)