I have created a .proto file and the ProtoBufTool successfully created .cs file. I am kinda new to csharp and I am trying to set the extension fields. But not sure how to do it? Does anybody have any examples how to use 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 that got 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); }
}
}