Generate .proto file from a custom RuntimeTypeModel in protobuf-net

1.6k views Asked by At

Using protobuf-net, I wish to generate a .proto file from a type model other than RuntimeTypeModel.Default:

RuntimeTypeModel myModel = TypeModel.Create();
myModel.Add(typeof(MyClass), true);
...
string myProto = Serializer.GetProto<MyClass>(); // Does not work, as it references RuntimeTypeModel.Default
  • How can I generate a .proto file in this case?
  • Inferring from the source code of GetProto(), should I simply call myModel.GetSchema(typeof(MyClass))?
1

There are 1 answers

0
bavaza On

Since no one answered so far:
Calling myModel.GetSchema(typeof(MyClass)) did work, though I'm not sure this is the correct method.