Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ internal override bool OnTryRead(ref Utf8JsonReader reader, Type typeToConvert,

if (state.Current.PropertyState < StackFramePropertyState.ReadValue)
{
if (!jsonPropertyInfo.CanDeserialize)
if (!jsonPropertyInfo.HasSetter)
{
if (!reader.TrySkip())
{
Expand Down Expand Up @@ -289,7 +289,7 @@ internal sealed override bool OnTryWrite(
for (int i = 0; i < properties.Count; i++)
{
JsonPropertyInfo jsonPropertyInfo = properties[i].Value;
if (jsonPropertyInfo.CanSerialize)
if (jsonPropertyInfo.HasGetter)
{
// Remember the current property for JsonPath support if an exception is thrown.
state.Current.JsonPropertyInfo = jsonPropertyInfo;
Expand All @@ -305,7 +305,7 @@ internal sealed override bool OnTryWrite(

// Write extension data after the normal properties.
JsonPropertyInfo? extensionDataProperty = jsonTypeInfo.ExtensionDataProperty;
if (extensionDataProperty?.CanSerialize == true)
if (extensionDataProperty?.HasGetter == true)
{
// Remember the current property for JsonPath support if an exception is thrown.
state.Current.JsonPropertyInfo = extensionDataProperty;
Expand Down Expand Up @@ -339,7 +339,7 @@ internal sealed override bool OnTryWrite(
while (state.Current.EnumeratorIndex < propertyList.Count)
{
JsonPropertyInfo jsonPropertyInfo = propertyList[state.Current.EnumeratorIndex].Value;
if (jsonPropertyInfo.CanSerialize)
if (jsonPropertyInfo.HasGetter)
{
state.Current.JsonPropertyInfo = jsonPropertyInfo;
state.Current.NumberHandling = jsonPropertyInfo.EffectiveNumberHandling;
Expand Down Expand Up @@ -368,7 +368,7 @@ internal sealed override bool OnTryWrite(
if (state.Current.EnumeratorIndex == propertyList.Count)
{
JsonPropertyInfo? extensionDataProperty = jsonTypeInfo.ExtensionDataProperty;
if (extensionDataProperty?.CanSerialize == true)
if (extensionDataProperty?.HasGetter == true)
{
// Remember the current property for JsonPath support if an exception is thrown.
state.Current.JsonPropertyInfo = extensionDataProperty;
Expand Down Expand Up @@ -415,7 +415,7 @@ protected static void ReadPropertyValue(
bool useExtensionProperty)
{
// Skip the property if not found.
if (!jsonPropertyInfo.CanDeserialize)
if (!jsonPropertyInfo.HasSetter)
{
reader.Skip();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected sealed override bool ReadAndCacheConstructorArgument(ref ReadStack sta

bool success = jsonParameterInfo.ConverterBase.TryReadAsObject(ref reader, jsonParameterInfo.Options!, ref state, out object? arg);

if (success && !(arg == null && jsonParameterInfo.IgnoreDefaultValuesOnRead))
if (success && !(arg == null && jsonParameterInfo.IgnoreNullTokensOnRead))
{
((object[])state.Current.CtorArgumentState!.Arguments)[jsonParameterInfo.ClrInfo.Position] = arg!;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static bool TryRead<TArg>(

bool success = converter.TryRead(ref reader, info.PropertyType, info.Options!, ref state, out TArg? value);

arg = value == null && jsonParameterInfo.IgnoreDefaultValuesOnRead
arg = value == null && jsonParameterInfo.IgnoreNullTokensOnRead
? (TArg?)info.DefaultValue! // Use default value specified on parameter, if any.
: value!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private void ReadConstructorArguments(ref ReadStack state, ref Utf8JsonReader re
out _,
createExtensionProperty: false);

if (jsonPropertyInfo.CanDeserialize)
if (jsonPropertyInfo.HasSetter)
{
ArgumentState argumentState = state.Current.CtorArgumentState!;

Expand Down Expand Up @@ -452,7 +452,7 @@ private static bool HandlePropertyWithContinuation(
{
if (state.Current.PropertyState < StackFramePropertyState.ReadValue)
{
if (!jsonPropertyInfo.CanDeserialize)
if (!jsonPropertyInfo.HasSetter)
{
if (!reader.TrySkip())
{
Expand Down Expand Up @@ -486,7 +486,7 @@ private static bool HandlePropertyWithContinuation(
}
}

Debug.Assert(jsonPropertyInfo.CanDeserialize);
Debug.Assert(jsonPropertyInfo.HasSetter);

// Ensure that the cache has enough capacity to add this property.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal abstract class JsonParameterInfo
// The default value of the parameter. This is `DefaultValue` of the `ParameterInfo`, if specified, or the CLR `default` for the `ParameterType`.
public object? DefaultValue { get; private protected set; }

public bool IgnoreDefaultValuesOnRead { get; private set; }
public bool IgnoreNullTokensOnRead { get; private set; }

// Options can be referenced here since all JsonPropertyInfos originate from a JsonTypeInfo that is cached on JsonSerializerOptions.
public JsonSerializerOptions? Options { get; set; } // initialized in Init method
Expand Down Expand Up @@ -62,7 +62,7 @@ public virtual void Initialize(JsonParameterInfoValues parameterInfo, JsonProper
PropertyType = matchingProperty.PropertyType;
NameAsUtf8Bytes = matchingProperty.NameAsUtf8Bytes!;
ConverterBase = matchingProperty.EffectiveConverter;
IgnoreDefaultValuesOnRead = matchingProperty.IgnoreDefaultValuesOnRead;
IgnoreNullTokensOnRead = matchingProperty.IgnoreNullTokensOnRead;
NumberHandling = matchingProperty.EffectiveNumberHandling;
MatchingPropertyCanBeNull = matchingProperty.PropertyTypeCanBeNull;
}
Expand Down
Loading