AugustoAngeletti / protobuf-net

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

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
Seems that a fix for this way overdue. We have automated build for a central 
repository of proto definitions and we can't guard against people checking in 
"value" properties..

Original comment by mAbushar...@hotmail.com on 12 Jun 2013 at 12:30

GoogleCodeExporter commented 9 years ago
Attached is a fix for this bug.. sorry can't access SVN at the moment. Note 
that this also includes a fix for 

Original comment by mAbushar...@hotmail.com on 12 Jun 2013 at 2:54

Attachments:

GoogleCodeExporter commented 9 years ago
the fix above is also for 142..

Original comment by mAbushar...@hotmail.com on 12 Jun 2013 at 2:55