(C#) Deserializing with a runtime provided .proto schema

25 views
Skip to first unread message

Darin Dimitrov

unread,
Apr 15, 2022, 10:13:32 AMApr 15
to Protocol Buffers

I am looking for a way to deserialize a binary protobuf message using a .proto schema provided at runtime. Ideally that would deserialize to some dynamic object or a wrapper which can be used to query for property names and values. Is this a supported scenario?

So I guess the process will involve those steps:

  1. Compile the .proto text schema to its binary representation
  2. Feed the binary schema along with the protobuf binary message to some parser/deserializer

My ultimate goal is to provide the same functionality in C# as the "protoc —decode" command - a human readable representation of the message.

Deanna Garcia

unread,
May 2, 2022, 2:07:45 PMMay 2
to Protocol Buffers
Protobuf doesn't directly support deserialization like this. You could use JsonFormatter to convert to JSON and deserialize from there. Your best option is probably to look into third party libraries that provide deserialization functionality for protobufs.
Reply all
Reply to author
Forward
0 new messages