AvroConvert icon indicating copy to clipboard operation
AvroConvert copied to clipboard

Private fields marked with [DataMember] attribute are ignored during serialization/deserialization

Open AdrianStrugala opened this issue 4 years ago • 0 comments

[DataMember] fields are resolved during schema generation.

There is no easy way (without significant performance hit) for serialization and deserialization of private fields. If you feel, that this is your case - please leave a comment down below. Maybe we'll figure out the right solution.

Serialization code snippet

 var privateFields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
                    var targetField = privateFields.FirstOrDefault(f => f.Name.Contains(name));

                    value = targetField?.GetValue(recordObj);

AdrianStrugala avatar Aug 30 '21 08:08 AdrianStrugala