Fix loading extra assemblies by only filtering for ByRef types on default members

This commit is contained in:
James Newton-King
2019-05-17 13:13:30 +12:00
parent 197a00ce77
commit a7471ae0b9
@@ -233,8 +233,10 @@ namespace Newtonsoft.Json.Serialization
MemberSerialization memberSerialization = JsonTypeReflector.GetObjectMemberSerialization(objectType, ignoreSerializableAttribute);
// Exclude index properties
// Do not filter ByRef types here because accessing FieldType/PropertyType can trigger additonal assembly loads
IEnumerable<MemberInfo> allMembers = ReflectionUtils.GetFieldsAndProperties(objectType, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
.Where(FilterMembers);
.Where(m => m is PropertyInfo p ? !ReflectionUtils.IsIndexedProperty(p) : true);
List<MemberInfo> serializableMembers = new List<MemberInfo>();
@@ -245,6 +247,7 @@ namespace Newtonsoft.Json.Serialization
#endif
#pragma warning disable 618
// Exclude index properties and ByRef types
List<MemberInfo> defaultMembers = ReflectionUtils.GetFieldsAndProperties(objectType, DefaultMembersSearchFlags)
.Where(FilterMembers).ToList();
#pragma warning restore 618