Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5382

Netstd default list/set enums values are generated incorrectly in some cases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 0.14.0, 0.15.0, 0.14.1
    • 0.15.0
    • netstd - Compiler
    • None

    Description

      Creating the following 2 thrift files:

      Enums.thrift

      namespace * enums
      
      enum FoobarEnum {    
          Val_1 = 0,
          Val_2 = 1
      }
      

      Service.thrift

      namespace * service
      
      include "Enums.thrift"
      
      struct RequestModel {    
          // Breaks    
          1: optional set<Thriftxxxx.objs.FoobarEnum> data_1 = [ FoobarEnum.Val_1, FoobarEnum.Val_2 ],    
          // Breaks    
          2: optional list<Thriftxxxx.objs.FoobarEnum> data_2 = [ FoobarEnum.Val_1, FoobarEnum.Val_2 ],    
          // Works    
          3: optional Thriftxxxx.objs.FoobarEnum data_3 = FoobarEnum.Val_1
      }
      
      service Test {    
         void CallMe(         
              1 : RequestModel foo,    
         )
      }
      
      

      Will generate a cs file that when compiled throws the following error for 2 items in the set and 2 items in the list:

       

      RequestModel.cs(96,24): error CS0103: The name 'FoobarEnum' does not exist in the current context
      

      Generated code from the RequestModel looks like this

      public RequestModel()    
      {      
          this._data_1 = new THashSet<global::Thriftxxxx.objs.FoobarEnum>();                        
          this._data_1.Add(FoobarEnum.Val_1);
          this._data_1.Add(FoobarEnum.Val_2);
          this.__isset.data_1 = true;
          this._data_2 = new List<global::Thriftxxxx.objs.FoobarEnum>();
          this._data_2.Add(FoobarEnum.Val_1);
          this._data_2.Add(FoobarEnum.Val_2);
          this.__isset.data_2 = true;
          this._data_3 = global::Thriftxxxx.objs.FoobarEnum.Val_1; 
          this.__isset.data_3 = true;    
      }
      

      The code in the FoobarEnum elements in the Add() methods are missing the namespace.
       

      Attachments

        Issue Links

          Activity

            People

              thomasbruggink Thomas Bruggink
              thomasbruggink Thomas Bruggink
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m