I wanna generate C# protobuf code with customize attributes. such as:
public sealed partial class LoginIn : pb::IMessage<LoginIn>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
[mycall] // customize attributes
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] // original
public LoginIn() {
OnConstruction();
}
... // rest code
With partial class
, you can add attributes (and members) to the type, but you can't add attributes to individual members, so: you can't do anything simple here. Effectively, you'd need to tweak the code-gen itself (meaning: create your own version of the protoc
addin), which is far from ideal.
The other option is manually editing the generated code - again: far from ideal.
Before doing either of those, I'd have to ask myself some serious questions about [mycall]
and how important it is, what it does, and whether adding it to the serialization model is necessary, vs creating my own domain model that can have any attributes you want, and mapping between the domain model and the serialization model.