I created a .proto file, and ProtoBufTool successfully created a .cs file. I am new to csharp and I am trying to set extension fields. But do not know how to do this? Does anyone have examples of using extensions using protobuf-net.
My .proto file:
package messages; message DMsg { optional int32 msgtype = 1; extensions 100 to max; } extend DMsg { optional string fltColumns = 101; }
Here is the class created:
//------------------------------------------------------------------------------ // // This code was generated by a tool. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ // Generated from: message.proto namespace messages { [global::System.Serializable, global::ProtoBuf.ProtoContract( Name=@ "DMsg")] public partial class DMsg : global::ProtoBuf.IExtensible { public DMsg() {} private int _msgtype = default(int); [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@ "msgtype", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)][global::System.ComponentModel.DefaultValue(default(int))] public int msgtype { get { return _msgtype; } set { _msgtype = value; } } private global::ProtoBuf.IExtension extensionObject; global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } }
source share