Is there a way to have a "base" protobuf with a set of common fields,  and
then have projects/apps extend that with their own custom fields? We're
trying to minimize copy/pasting of the same fields all over the place, for
messages that will have a lot of common fields, that then need
specialization within different parts of the codebase.

Say something like:

message BaseProtobuf {
    required int id = 1;
    required int field1 = 2;
    required string label = 3;
}

and then multiple files like:

message CustomProtobuf1 extend BaseProtobuf {
    required int customId = 11;
    optional string customLabel = 12;
}

message CustomProtobuf2 extend BaseProtobuf {
    required int anotherCustomId = 11;
    optional string customLabel = 12;
}

Of course, at compile time, the user would have to specify the location of
the base protobuf definitions, if any, since protoc would need all of them
to generate the java source code.

I do know about the import functionality, but that's more targeted for type
and enum definitions, not for inheriting base fields, so it doesn't really
address my question above.

Thanks,

Marcos Juarez

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to