protobuf-net v3 中的数组或列表中的空对象

Posted

技术标签:

【中文标题】protobuf-net v3 中的数组或列表中的空对象【英文标题】:Null object in an array or list in protobuf-net v3 【发布时间】:2020-08-30 03:26:52 【问题描述】:

在 protobuf-net v2.46 中,我可以通过添加以下代码来序列化和反序列化空列表条目。

RuntimeTypeModel.Default[typeof(SerializableInnerList<MySerializableInnerObject>)][1].SupportNull = true;

但是在最新版本的 Protobuf-net(目前是 v3.0.29)中,我看到了错误:'ValueMember.SupportNull.set' is obsolete: 'Nullable list elements are not currently implemented'

这是否意味着如果我想要可以为空的列表项,我必须使用旧版本的 protobuf-net,还是在 protobuf-net 的 v3 中有新的方法来实现这一点?

【问题讨论】:

【参考方案1】:

现在:这根本没有实现。但与“动态类型”(我非常想杀死它)不同,这个可能是我可以再看看的一个 - 更多关于时间和需要发布而不是不支持。让我将它添加到我的列表中。

【讨论】:

感谢您的回复马克!如果您将此功能添加到 v3.x,您能否使其向后兼容使用版本 2.x 序列化的反序列化对象? @tjsmith 这绝对是不可侵犯的要求,是的

以上是关于protobuf-net v3 中的数组或列表中的空对象的主要内容,如果未能解决你的问题,请参考以下文章

ProtoBuf-Net 错误消息 - “不支持嵌套或锯齿状列表和数组”

具有代理和继承层次结构的 protobuf-net v3

Protobuf-net:嵌套的 IEnumerable 对象

使用 protobuf-net 序列化数组时如何处理空值?

protobuf-net 使用啥基本序列化器来输出字节数组?

如何使用 protobuf-net 序列化/反序列化锯齿状/嵌套数组?