Protobuf-net: How to exclude read-only properties(with only getters) from porto contract of implicit all public fields?

StackOverflow https://stackoverflow.com/questions/21676719

  •  09-10-2022
  •  | 
  •  

Question

I am using protobuf-net serialization in my project with stating [ProtoContract(ImplicitFields = ImplicitFields.AllPublic)] approach.

My class has some properties with only getters in them. i.e read-only properties. Serializer tries to serialize those properties but throws an error saying unable to change this property.

Currently I have added [ProtoIgnore] attribute on such properties, which is working.

What I wanted to know was whether there is an alternative method to make it ignore all properties that don't have setters. Thanks in Advance.

Était-ce utile?

La solution

Nope; all is all. Actually, I very rarely recommend using implicit fields (see the warnings in the intellisense).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top