1

我们正在将应用程序中的 protobuf-net 库引用从 v2.0.50727 更新到 v4.0.30319。更新 protobuf dll 后,我们发现在最新版本的 prtobuf-net 中,ProtomemberAttribute 中缺少 OverwriteList(在我们的项目中使用)。

有人可以让我知道我们应该在 OverwriteList 中使用什么,这样我们就不会对 protobuf 更新产生任何影响吗?

以下是我从 Protobuf 版本(我们正在更新的)元数据中看到的内容:

#region Assembly protobuf-net.dll, v4.0.30319
// C:\src\MyProjectName\lib\protobuf-net\protobuf-net.dll
#endregion

using System;

namespace ProtoBuf
{
    // Summary:
    //     Declares a member to be used in protocol-buffer serialization, using the
    //     given Tag. A DataFormat may be used to optimise the serialization format
    //     (for instance, using zigzag encoding for negative numbers, or fixed-length
    //     encoding for large values.
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public class ProtoMemberAttribute : Attribute
    {
        // Summary:
        //     Creates a new ProtoMemberAttribute instance.
        //
        // Parameters:
        //   tag:
        //     Specifies the unique tag used to identify this member within the type.
        public ProtoMemberAttribute(int tag);

        // Summary:
        //     Gets or sets the data-format to be used when encoding this value.
        public DataFormat DataFormat { get; set; }
        //
        // Summary:
        //     Gets or sets a value indicating whether this member is mandatory.
        public bool IsRequired { get; set; }
        //
        // Summary:
        //     Gets or sets the original name defined in the .proto; not used during serialization.
        public string Name { get; set; }
        //
        // Summary:
        //     Gets or sets a value indicating whether this member is packed (lists/arrays).
        public MemberSerializationOptions Options { get; set; }
        //
        // Summary:
        //     Gets the unique tag used to identify this member within the type.
        public int Tag { get; }
    }
}

谢谢,基兰

4

1 回答 1

0

那还在那里;它没有被删除或以任何方式更改。请检查您是否引用了正确版本的 protobuf-net - 我怀疑您引用的是 1.0.0.282。在下面我使用来自 NuGet 的当前版本(2.0.0.668):

在此处输入图像描述

特别是,缺少IsPacked(在问题的元数据中)表明您使用的版本真的很旧。

于 2013-10-23T12:52:26.860 回答