You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Thomas Bruggink (Jira)" <ji...@apache.org> on 2021/03/27 07:04:00 UTC
[jira] [Created] (THRIFT-5382) Netstd default list/set enums values
are generated incorrectly
Thomas Bruggink created THRIFT-5382:
---------------------------------------
Summary: Netstd default list/set enums values are generated incorrectly
Key: THRIFT-5382
URL: https://issues.apache.org/jira/browse/THRIFT-5382
Project: Thrift
Issue Type: Bug
Components: netstd - Compiler
Affects Versions: 0.14.1, 0.14.0, 0.15.0
Reporter: Thomas Bruggink
Creating the following 2 thrift files:
Enums.thrift
{code:java}
namespace * enums
enum FoobarEnum {
Val_1 = 0,
Val_2 = 1
}
{code}
Service.thrift
{code:java}
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,
)
}
{code}
Will generate a cs file that when compiled throws the following error for 2 items in the set and 2 items in the list:
{code:java}
RequestModel.cs(96,24): error CS0103: The name 'FoobarEnum' does not exist in the current context
{code}
Generated code from the RequestModel looks like this
{code:java}
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;
}
{code}
The code in the FoobarEnum elements in the Add() methods are missing the namespace.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)