【发布时间】:2012-09-09 10:07:52
【问题描述】:
我正在使用 protobuf-net r580 中包含的 Protogen 来编译以下 .proto 文件:
message TestMessage2 {
required int32 someint = 1;
}
我发现生成的代码使用 TwosComplement 线格式很奇怪:
Private _someint As Integer
<Global.ProtoBuf.ProtoMember(1, IsRequired:=True, Name:="someint", DataFormat:=Global.ProtoBuf.DataFormat.TwosComplement)> _
Public Property someint As Integer
而不是更优化的默认 varint 类型。这是预期的行为吗?
【问题讨论】:
-
正如 Jon 所指出的,.proto 模式中的“int32”是必需才能使用常规(非锯齿形)varint 编码,这正是这里发生的情况。如果您想要 zigzag varint 编码,请指定“sint32”。无论哪种方式,这都是一个变种。唯一的问题是:它是曲折的。
标签: protobuf-net protogen