Search code examples
c#protocol-buffersprotobuf-net

Protobuf3 - Protobuf-net get Options/Extensions from C#


I have an opt.proto file that has the following structure:

extend google.protobuf.MessageOptions {
  repeated string class_attr = 3003;
}

extend google.protobuf.FieldOptions {
  repeated string field_attr = 3004;
}

and another classext.proto that has the import from the opt.proto file:


message Stream
{
    option (class_attr) = "TestClassAttribute";
    option (class_attr) = "TestClassAttribute2";
    
    string id = 1 [(field_attr) = "TestFieldAttribute", (field_attr) = "TestFieldAttribute"];
    
    string description = 2;

    string path = 3;
}

When compiling I need to have access to the extensions and their values so I can add more information when needed. So far I can only access the name of the fields (class_attr, field_attr), but I can't access their values.

I saw that for c++ there is something like GetExtension(option).

According to this question in 2016, there was no such type of implementation,

Has this been resolved in any way?

Merci.


Solution

  • To solve this, I ended up creating my own reader that loads the information so I can scroll through as needed.