Is it possible to (de)serialize a POCO type using neither protobuf-net attributes nor explicitly adding types into the model?
Is it possible to (de)serialize a POCO type using neither protobuf-net attributes nor explicitly
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
At the moment – in short, no. It needs to have a basic understanding of how you intend it to operate. I guess maybe I could add something to let you specify a default strategy for completely unadorned types (things that aren’t
DataContract,ProtoContractorXmlType), but the most appropriate option there would be “all public members” (much likeXmlSerializer).The reason I don’t want to encourage this is that it is brittle. Because of how the protobuf spec is defined, all you get is field-numbers. It is easy enough to say “ok, order them alphabetically and use their positions”, but that is not safe if you ever want to change the type. And let’s face it, we all do. You’d be amazed how often I add an
AardvarkCountproperty, which messes with alphabetical orderings.Hence, I don’t want to make it easy to get people into a position where they risk data integrity. Because I don’t like people shouting at me. If there was a global default policy, it would be easy to use that policy without realising it, which is when you start getting into trouble.
I do, however, intend making it easier to choose those strategies on a per-type basis (the code all exists, it just isn’t in the public API) – for example:
(the
ImplicitFieldsstuff already exists, back to v1 days) or maybe just:any help? does the reasoning make sense?