You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jin Feng (JIRA)" <ji...@apache.org> on 2013/02/22 03:13:12 UTC

[jira] [Commented] (THRIFT-1026) C# default value code generation problem

    [ https://issues.apache.org/jira/browse/THRIFT-1026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13583824#comment-13583824 ] 

Jin Feng commented on THRIFT-1026:
----------------------------------

[~carlyeks] in what version is fixed? I'm having the same problem in generated java thrift struct where a default value for a field is initialized in the constructor but isset for the field is false.
                
> C# default value code generation problem
> ----------------------------------------
>
>                 Key: THRIFT-1026
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1026
>             Project: Thrift
>          Issue Type: Bug
>          Components: C# - Compiler
>    Affects Versions: 0.5
>         Environment: Windows, Mac
>            Reporter: William Blinn
>
> I have a thrift file that looks like this:
> {code}
> // Time stamp with a timezone specification for normalization.
> struct DateTimeZone
> {
>     1: i64 ticks,
>     2: optional string timeZone = "UTC",
> }
> {code}
> When I generate C#, it produces code like this:
> {code}
>   [Serializable]
>   public partial class DateTimeZone : TBase
>   {
>     private long _ticks;
>     private string _timeZone;
>     public long Ticks
>     {
>       get
>       {
>         return _ticks;
>       }
>       set
>       {
>         __isset.ticks = true;
>         this._ticks = value;
>       }
>     }
>     public string TimeZone
>     {
>       get
>       {
>         return _timeZone;
>       }
>       set
>       {
>         __isset.timeZone = true;
>         this._timeZone = value;
>       }
>     }
>     public Isset __isset;
>     [Serializable]
>     public struct Isset {
>       public bool ticks;
>       public bool timeZone;
>     }
>     public DateTimeZone() {
>       this.timeZone = "UTC";
>     }
> ...
> {code}
> The constructor, which sets the default value should be this.TimeZone = "UTC" because the property is TimeZone, not timeZone. The constructor should set the property rather than the field so that __isset is marked properly.
> The compile error I get when I try to compile the code that thrift generates is like this:
> {code}
>       [csc] d:\code\Thrift\Generated\DateTimeZone.cs(59,12): error CS1061: 'Thrift.Generated.DateTimeZone' does not contain a definition for 'timeZone' and no extension method 'timeZone' accepting a first argument of type 'Thrift.Generated.DateTimeZone' could be found (are you missing a using directive or an assembly reference?)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira