Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Jul 1, 2022
1 parent 2b03985 commit c9cb9bd
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,7 @@ internal ICustomAttributeProvider? AttributeProvider
{
VerifyMutable();

switch (_attributeProvider = value)
{
case PropertyInfo propertyInfo:
{
MemberName = propertyInfo.Name;
IsVirtual = propertyInfo.IsVirtual();
MemberType = MemberTypes.Property;
break;
}
case FieldInfo fieldInfo:
{
MemberName = fieldInfo.Name;
MemberType = MemberTypes.Field;
break;
}
default:
// Don't set any metadata when value is unsupported MemberInfo type
break;
}
_attributeProvider = value;
}
}

Expand Down Expand Up @@ -546,7 +528,26 @@ internal string GetDebugInfo(int indent = 0)
internal void InitializeUsingMemberReflection(MemberInfo memberInfo)
{
Debug.Assert(AttributeProvider == null);
Debug.Assert(memberInfo is FieldInfo or PropertyInfo);

switch (AttributeProvider = memberInfo)
{
case PropertyInfo propertyInfo:
{
MemberName = propertyInfo.Name;
IsVirtual = propertyInfo.IsVirtual();
MemberType = MemberTypes.Property;
break;
}
case FieldInfo fieldInfo:
{
MemberName = fieldInfo.Name;
MemberType = MemberTypes.Field;
break;
}
default:
Debug.Fail("Only FieldInfo and PropertyInfo members are supported.");
break;
}

DeterminePoliciesFromMember(memberInfo);
DeterminePropertyNameFromMember(memberInfo);
Expand All @@ -557,7 +558,6 @@ internal void InitializeUsingMemberReflection(MemberInfo memberInfo)
}

IsExtensionData = memberInfo.GetCustomAttribute<JsonExtensionDataAttribute>(inherit: false) != null;
AttributeProvider = memberInfo;
}

internal bool IgnoreDefaultValuesOnRead { get; private set; }
Expand Down

0 comments on commit c9cb9bd

Please sign in to comment.