andyQn / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

ProtoGen -p option to generate nullable properties for optional message fields without default #375

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Please include an e-mail address if this might need a dialogue!
==============

What steps will reproduce the problem?
1. create .proto with optional field without default 
message Test{
   optional int32 IntValue = 1;
}
2. run protogen.exe -o:test.cs -i:"Test.proto"

What is the expected output? 

test.cs contains:
    private int? _IntValue = null;
    [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"IntValue", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
    [global::System.ComponentModel.DefaultValue(null)]
    public int? IntValue
    {
      get { return _IntValue; }
      set { _IntValue = value; }
    }

What do you see instead?
    private int _IntValue = default(int);
    [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"IntValue", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
    [global::System.ComponentModel.DefaultValue(default(int))]
    public int IntValue
    {
      get { return _IntValue; }
      set { _IntValue = value; }
    }

What version of the product are you using? On what operating system?
r622

Please provide any additional information below.
I'm aware of -p:detectMissing but nullable property is much more convinient 
than additional bool Sepcified property.

Original issue reported on code.google.com by Konstant...@gmail.com on 19 Apr 2013 at 5:25