I think the easiest solution would be to include the .proto file that
defines the custom option in the serialized descriptor set. I assume you're
generating the .desc file by invoking protoc with -o or
--descriptor_set_out, so just make sure to add the custom option .proto
file as one of the command line arguments to protoc when you do that.

On Tue, Feb 9, 2021 at 5:39 AM Marc Schafer <[email protected]> wrote:

> Parsing fails on a .desc file generated from a message with a custom
> option as shown below. I understand this is happening because the message
> defined in descriptor.proto doesn't know about my extension but I am not
> sure how to fix it. I'm using C++.
>
> Here is my .proto:
> syntax = "proto3";
> package foo;
>
> // extending MessageOptions prevents parsing of generated .desc
> import "google/protobuf/descriptor.proto";
>
> // extensions start at 1000
> extend google.protobuf.MessageOptions {
>   optional string my_option = 1992;
> }
>
>
> message SearchRequest {
>   option (my_option) = "custom";
>   string query = 1;
>   int32 page_number = 2;
>   int32 result_per_page = 3;
> }
>
> -Best
> Marc
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/614101fd-9571-448b-9b29-0ae050e536cfn%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/614101fd-9571-448b-9b29-0ae050e536cfn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr4fc%3DOnpjvS6xRVKxwNBwC4jB4n0mhLwxTy1_32%3DB72jw%40mail.gmail.com.

Reply via email to