是否可以通过生成 .proto 文件使用 python 反序列化在 c# 中使用 protobuf-net 序列化的对象?

Can an object serialized with protobuf-net in c# be deserialized with python by generating a .proto file?

问题是数据的生产者没有 .proto 定义,只有 .cs 文件。

从其他问题来看,这似乎是可能的,但是是否有工具可以将 .cs protobuf-net 定义转换为 .proto 文件,以便我可以使用该文件在 python 中进行反序列化?

string proto = Serializer.GetProto<YourRootType>();

请注意,如果您使用 DateTimeTimeSpan,理想情况下您应该使用 DataFormat.WellKnown - 分别使用 TimestampDuration - 但是,这是对现有数据的重大更改(这是通过 [ProtoMember(...)])