I am invoking protoc –descriptor_set_out on the .proto file with contents described below that include the definition of the custom option. I’m not sure what else you are suggesting I include.

 

I attached the .proto file to clarify the reproduction steps.

protoc –descriptor_set_out simple.proto

 

Use this snippet of code to parse the resulting .desc file:

 

    fdiName = “simple.desc";

    std::ifstream fdi(fdiName);

    google::protobuf::FileDescriptorSet fds;

    auto r = fds.ParseFromIstream(&fdi);

    assert(r);

 

The assertion will fail

 

Best,

Marc

 

 

From: Adam Cozzette
Sent: Friday, February 12, 2021 2:56 PM
To: Marc Schafer
Cc: Protocol Buffers
Subject: Re: [protobuf] Parsing of .desc fails for message with custom option

 

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 <space...@plunk.org> 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 protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/614101fd-9571-448b-9b29-0ae050e536cfn%40googlegroups.com.

 

--
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 protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/60735A61-EDB0-4CD6-B0CE-7B8F25355BE9%40hxcore.ol.

Attachment: simple.proto
Description: Binary data

Reply via email to