pizheng/protobuf-net

naming protobuf field as "value" results in compilation error in XXXSpecified (valueSpecified) setter

Opened this issue · 0 comments

Compilation error:
Error   Type of conditional expression cannot be determined because there is no 
implicit conversion between 'bool' and 'string' 

    private string _value;
    [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
    public string value
    {
      get { return _value?? ""; }
      set { _value = value; }
    }

[global::System.Xml.Serialization.XmlIgnore]
    [global::System.ComponentModel.Browsable(false)]
    public bool valueSpecified
    {
      get { return _value != null; }
->>>>>      set { if (value == (_value== null)) _value = value ? value : 
(string)null; }
    }

Suggested workarounds:
1. rename "value" property in proto file to something different (avoid using 
keywords).
2. When code of XXXSpecified is generated add "this." to reference every class 
member.


Original issue reported on code.google.com by siniy...@gmail.com on 5 Apr 2011 at 5:58