On the most recent version of JSON.NET for Unity3D I am receiving the following compiler warning message:
[CS0618] `Newtonsoft.Json.Serialization.DefaultContractResolver.DefaultMembersSearchFlags' is obsolete:
`DefaultMembersSearchFlags is obsolete. To modify the members serialized inherit from DefaultContractResolver and override the GetSerializableMembers method instead.'
The signature of the GetSerializableMembers method is:
protected virtual List<MemberInfo> GetSerializableMembers(Type objectType)
I'm very confused how to override this method to accomplish the same logical equivalent we used to have when simply setting the DefaultMembersSearchFlags. Our previous usage we need to move into an override of GetSerializableMembers was:
contractResolver = new DefaultContractResolver() {
DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic
};
Does an example exist of a working override for this method? Google is failing me.
Here's what I've tried so far by reverse-engineering the current usage of DefaultMembersSearchFlags in DefaultContractResolver.cs:
private class ContractResolver : DefaultContractResolver {
override protected List<MemberInfo> GetSerializableMembers(Type objectType) {
BindingFlags DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
return ReflectionUtils.GetFieldsAndProperties(objectType, DefaultMembersSearchFlags)
.Where(m => !ReflectionUtils.IsIndexedProperty(m)).ToList();
}
}
Problem is... ReflectionUtils doesn't seem to be importable from the current JSON.NET package and rolling my own version of all that sounds like a rabbit trail when this should be 'easy'... right?