protogen.exe
generates this pattern for a proto2
message field of type long
:
private long _Count = default(long);
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"Count", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(long))]
public long Count
{
get { return _Count; }
set { _Count = value; }
}
but as proto2
does not include a date-time type ( and protobuf-net
does not support proto3
which includes google.protobuf.Timestamp
) it's not clear how to represent DateTime
in manually coded C# proto object.
This is probably wrong :
private DateTime _When = DateTime.MinValue;
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"When", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(DateTime.MinValue)]
public DateTime When
{
get { return _When; }
set { _When = value; }
}
What is the correct way to decorate DateTime
properties for use with protobuf-net
?