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

[jira] [Created] (THRIFT-1788) C#: Constants static constructor does not compile

Carl Yeksigian created THRIFT-1788:
--------------------------------------

             Summary: C#: Constants static constructor does not compile
                 Key: THRIFT-1788
                 URL: https://issues.apache.org/jira/browse/THRIFT-1788
             Project: Thrift
          Issue Type: Bug
          Components: C# - Compiler
    Affects Versions: 0.9, 0.8
            Reporter: Carl Yeksigian
            Assignee: Carl Yeksigian
             Fix For: 1.0


The following Thrift IDL does not correctly compile to C# (from test/ConstantsDemo.thrift):

{code}
struct thing {
  1: i32 hello,
  2: i32 goodbye
}

enum enumconstants {
  ONE = 1,
  TWO = 2
}

// struct thing2 {
//   /** standard docstring */
//   1: enumconstants val = TWO
// }

typedef i32 myIntType
const myIntType myInt = 3

//const map<enumconstants,string> GEN_ENUM_NAMES = {ONE : "HOWDY", TWO: "PARTNER"}

const i32 hex_const = 0x0001F

const i32 GEN_ME = -3523553
const double GEn_DUB = 325.532
const double GEn_DU = 085.2355
const string GEN_STRING = "asldkjasfd"

const map<i32,i32> GEN_MAP = { 35532 : 233, 43523 : 853 }
const list<i32> GEN_LIST = [ 235235, 23598352, 3253523 ]

const map<i32, map<i32, i32>> GEN_MAPMAP = { 235 : { 532 : 53255, 235:235}}

const map<string,i32> GEN_MAP2 = { "hello" : 233, "lkj98d" : 853, 'lkjsdf' : 098325 }

const thing GEN_THING = { 'hello' : 325, 'goodbye' : 325352 }

const map<i32,thing> GEN_WHAT = { 35 : { 'hello' : 325, 'goodbye' : 325352 } }

const set<i32> GEN_SET = [ 235, 235, 53235 ]

exception Blah {
  1:  i32 bing }

exception Gak {}

service yowza {
  void blingity(),
  i32 blangity() throws (1: Blah hoot )
}
{code}

The constructor generated does not use the correct property name, instead using the field name.

{code}
/**
 * Autogenerated by Thrift Compiler (0.8.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Thrift;
using Thrift.Collections;

public class Constants
{
  public static int   public static int hex_const = 31;
  public static int GEN_ME = -3523553;
  public static double GEn_DUB = 325.532;
  public static double GEn_DU = 85.2355;
  public static string GEN_STRING = "asldkjasfd";
  public static Dictionary<int, int> GEN_MAP = new Dictionary<int, int>();
  public static List<int> GEN_LIST = new List<int>();
  public static Dictionary<int, Dictionary<int, int>> GEN_MAPMAP = new Dictionary<int, Dictionary<int, int>>();
  public static Dictionary<string, int> GEN_MAP2 = new Dictionary<string, int>();
  public static thing GEN_THING = new thing();
  public static Dictionary<int, thing> GEN_WHAT = new Dictionary<int, thing>();
  public static THashSet<int> GEN_SET = new THashSet<int>();
  static Constants()
  {
    GEN_MAP[35532] = 233;
    GEN_MAP[43523] = 853;
    GEN_LIST.Add(235235);
    GEN_LIST.Add(23598352);
    GEN_LIST.Add(3253523);
    Dictionary<int, int> tmp0 = new Dictionary<int, int>();
    tmp0[532] = 53255;
    tmp0[235] = 235;
    GEN_MAPMAP[235] = tmp0;
    GEN_MAP2["hello"] = 233;
    GEN_MAP2["lkj98d"] = 853;
    GEN_MAP2["lkjsdf"] = 98325;
    GEN_THING.hello = 325;
    GEN_THING.goodbye = 325352;
    thing tmp1 = new thing();
    tmp1.hello = 325;
    tmp1.goodbye = 325352;
    GEN_WHAT[35] = tmp1;
    GEN_SET.Add(235);
    GEN_SET.Add(235);
    GEN_SET.Add(53235);
  }
}
{code}

I think it should be tmp1.Hello = 325, tmp1.Goodbye = 325352; this is in line with what the Java compiler produces.

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