2 options present themselves:
- if the generated code is a
partial
class, you can create a second partial class file for the same type, and add the attributes there - this is then part of the same type; in particular, note that[ProtoPartialMember(...)]
can be added to a type (multiple times), but describes a member; or if you want less maintenance,[ProtoContract(ImplicitFields=ImplicitFields.AllPublic)]
can be used to let the model take control of the rules (but please read the intellisense remarks onImplicitFields
before doing this) you can configure the type at runtime, using whatever rules you want, via
RuntimeTypeModel
:var metaType = RuntimeTypeModel.Default.Add(yourType, false); // TODO: some reflection that decides what members you want to serialize // and as what keys foreach(...) metaType.Add(member, key);