Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Patch Available
Description
Given the thrift IDL:
struct A { 0: i32 value } union AUnion { 0: A field1, 1: A field2, 2: i32 value }
We should generate a C# subclassing tree:
class A : TBase { int Value { get;set; } } abstract class AUnion : TBase { abstract object Data { get; } protected int field; abstract void WriteUnionField(TProtocol tprot); class field1 : AUnion { A _data; override object Data { get { return _data; } } public field1(A data) { this._data = data; this.field = 0; } } class field2 : AUnion { A _data; override object Data { get { return _data; } } public field2(A data) { this._data = data; this.field = 1; } } class value : AUnion { int _data; override object Data { get { return _data; } } public value(int data) { this._data = data; this.field = 2; } } }
This gives us creation syntax of:
var aunion = new AUnion.value(10);
This should be an optional parameter to the compiler since it is a breaking change to existing code.
Attachments
Attachments
Issue Links
- Dependency
-
THRIFT-4715 C# union "data" should be strongly-typed
- Closed
-
THRIFT-4722 Netcore union "data" should be strongly-typed
- Closed
- depends upon
-
THRIFT-1788 C#: Constants static constructor does not compile
- Closed