mercredi 22 juillet 2020

How to get custom options through a protobuf descriptor file

I have this in the .proto file:

test.proto:

syntax = "proto3";
import "google/protobuf/descriptor.proto";
extend google.protobuf.FileOptions{
    optional string myOption = 50000;
}

option (myOption) = "foo";

I then create the the descriptor file by doing: protoc --include_imports --descriptor_set_out="test.desc" test.proto

In the Java code I then open "test.desc" and get the FileDescriptor object for it. I want to be able to get the custom option I created.

When I print out FileDescriptor.getOptions() it shows my custom option but I don't know how to get myOption specifically.





Aucun commentaire:

Enregistrer un commentaire