Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get *.proto files based on c# classes

Tags:

protobuf-net

I have following use-case: there are several assemblies decorated with ProtoContract classes and I would like to generate proto files based on assemblies. So the question is how it can be done?

My first intention was to use Serailizer.GetProto but it is generic method which doesn't work for me because I only know class type in runtime.

Also why in r480 GetProto is not impelemented?

I'm aslo aware about VS08/10 but it doesn't seem to help in my scenario.

Thanks in advance.

like image 319
Sharov Avatar asked Jan 17 '23 05:01

Sharov


1 Answers

You are able to use the Serializer.GetProto method with a little reflection:

var method = typeof(Serializer).GetMethod("GetProto").MakeGenericMethod(type);
Func<string> getProto = Delegate.CreateDelegate(typeof(Func<string>), method);
var proto = getProto();
like image 117
Rich O'Kelly Avatar answered Apr 06 '23 00:04

Rich O'Kelly