问题描述
我有一个使用 protobuf 进行序列化的 .net 应用程序,我想创建一个可以与其通信的 Python 客户端.由于我的对象图非常复杂(而且我很忙),我想直接从 C# 类中快速生成 .proto 文件,如下所示:
I have a .net application that serializes using protobuf, and I wanted to create a python client that can communicate with it. Since my object graph is quite complex (and I am busy) I wanted to quickly generate the .proto files directly from the C# classes like this:
string proto = Serializer.GetProto<YourType>();
不幸的是,这个方法为我抛出了一个未实现的异常:'(
Unfortunately this method is throwing a not implemented exception for me :'(
我使用的是 12 月 11 日的版本
此功能是否已删除?我应该使用更新的版本吗?或者失败了,谁能推荐一个旧版本的,我可以暂时用来创建 .proto 文件?
Has this feature been dropped? Is there a newer version I should be using? Or failing that, can anyone recommend an older version of it that I can temporarily use to create the .proto files?
谢谢
推荐答案
这是很久以前重新实现的;它当然适用于 r580 及更高版本.
This was re-implemented quite a while ago now; it is certainly available in r580 and higher.
V1 is still available for download and should work in most reasonable cases. However, note that protobuf-net allows for more than the core specification - things like inheritance/generics don't have any meaning in .proto, and teen things like System.DateTime/System.Decimal need special handling. Basically, GetProto may get you most of the way there!
这篇关于Protobuf.net GetProto<Type>() 方法抛出未实现的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!