Hi all,

I have a protoc ruby plugin that does some codegen. I have defined the
following toy custom message option.

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
optional string custom = 600001;
}

message PingRequest {
option (custom) = "123";
}

Later in the plugin, we have the following piece of code that attempts to
read the custom option above. `request` below is just an instance of
"::Google::Protobuf::Compiler::CodeGeneratorRequest".

services = request.proto_file.flat_map do |file_desc|
file_desc = T.must(file_desc)

file_desc.message_type.map do |message_desc|
if message_desc.name == "PingRequest"
puts message_desc.options
end
end
end

Interesting enough, `message_desc.options` outputs
<Google::Protobuf::MessageOptions: uninterpreted_option: []>. I wonder if
this is expected, or do we have some other way to retrieve the custom
option.

Thanks,
Sean

-- 
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/CAGws8EeW7vWXLM%3DvWUefQ3dPsHVm5%2B7gDpZeinwNWMr7Zhf8SA%40mail.gmail.com.

Reply via email to