You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2012/12/09 18:55:21 UTC

[jira] [Commented] (THRIFT-1780) Add option to generate nullable values

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

Jens Geyer commented on THRIFT-1780:
------------------------------------

Nice!
But ... using your patch I get without nullable:

{code}
    private bool _Visible;

    public bool Visible
    {
      get
      {
        return _Visible;
      }
      set
      {
        __isset.Visible = true;
        this._Visible = value;
      }
    }
{code}


Same with nullable:
{code}
    private bool _Visible;

    public bool? Visible
    {
      get
      {
        return __isset.Visible ? (bool?)_Visible : null;
      }
      set
      {
        __isset.Visible = value.HasValue;
        if (value.HasValue) this._Visible = value.Value;
      }
    }
{code}

Couldn't the value be stored as the nullable, effectively combining both the value and the isset flag into one? That way the conversions now introduced in the getters could be avoided.

Something like this (not tested!):

{code}
    private bool? _Visible;

    public bool Visible
    {
      get
      {
        return _Visible;
      }
      set
      {
        _Visible = value;
      }
    }
{code}


Maybe if autoprops are mono-comaptible (?) even better:

{code}
    public bool? Visible { get; set;}
{code}


                
> Add option to generate nullable values
> --------------------------------------
>
>                 Key: THRIFT-1780
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1780
>             Project: Thrift
>          Issue Type: New Feature
>          Components: C# - Compiler
>            Reporter: Carl Yeksigian
>            Priority: Minor
>         Attachments: 1780.patch
>
>
> There should be an option to generate nullable value types for C#.
> If a value is not set, then it would return as null rather than default value. If a value is updated to null, then it would become unset.

--
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