假设我有一个枚举
public enum PricingFlags : long
其值为1000000000001000011111111110001000_2或4296080913。基本上是像这样的标志的集合
[Description("Aggregate")]
Aggregate = 1L << 7,
逻辑或运算。我正在使用2.3.1版。
我尝试在属性中添加EnumPassthru
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic, EnumPassthru = true)]
或在protobuf规范中,
RuntimeTypeModel.Default[typeof(PricingFlags)].EnumPassthru = true;
[谷歌搜索后,我发现https://github.com/protobuf-net/protobuf-net/issues/219告诉我,它应该可以工作,但是没有。我做错了吗?
我今天的建议是:声明一个影子属性(也许是私有的),该影子属性将数据公开很长时间,并在代码中进行强制转换。