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 22:57:20 UTC
[jira] [Updated] (THRIFT-1783) C# doesn't handle required fields
correctly
[ https://issues.apache.org/jira/browse/THRIFT-1783?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer updated THRIFT-1783:
-------------------------------
Description:
The following IDL
{code}
struct MyStruct {
1 : required i32 ID,
2 : optional bool someFlag,
3 : optional string Key
}
{code}
generates this code:
{code}
public partial class MyStruct : TBase
{
public int? ID { get; set; }
public bool? SomeFlag { get; set; }
public string Key { get; set; }
// more code
public void Write(TProtocol oprot) {
TStruct struc = new TStruct("MyStruct");
oprot.WriteStructBegin(struc);
TField field = new TField();
if (ID != null) {
field.Name = "ID";
field.Type = TType.I32;
field.ID = 1;
oprot.WriteFieldBegin(field);
oprot.WriteI32(ID.Value);
oprot.WriteFieldEnd();
}
if (SomeFlag != null) {
field.Name = "someFlag";
field.Type = TType.Bool;
field.ID = 2;
oprot.WriteFieldBegin(field);
oprot.WriteBool(SomeFlag.Value);
oprot.WriteFieldEnd();
}
if (Key != null) {
field.Name = "Key";
field.Type = TType.String;
field.ID = 3;
oprot.WriteFieldBegin(field);
oprot.WriteString(Key);
oprot.WriteFieldEnd();
}
oprot.WriteFieldStop();
oprot.WriteStructEnd();
}
{code}
which is unexpected, since the ID field is required and thus there's no need to maintrain the _isset flag for thuis fiel. Expected behaviour would be that
* the field is always written to the output
* it is ensured that the field is successfully read from the input (see C++ impl)
was:
The following IDL
{code}
{code}
generates this code:
{code}
{code}
which is unexpected, since the ID field is required and thus there's no need to maintrain the _isset flag for thuis fiel. Expected behaviour would be that
* the field is always written to the output
* it is ensured that the field is successfully read from the input (see C++ impl)
> C# doesn't handle required fields correctly
> -------------------------------------------
>
> Key: THRIFT-1783
> URL: https://issues.apache.org/jira/browse/THRIFT-1783
> Project: Thrift
> Issue Type: Bug
> Components: C# - Compiler
> Affects Versions: 0.9
> Reporter: Jens Geyer
> Fix For: 1.0
>
>
> The following IDL
> {code}
> struct MyStruct {
> 1 : required i32 ID,
> 2 : optional bool someFlag,
> 3 : optional string Key
> }
> {code}
> generates this code:
> {code}
> public partial class MyStruct : TBase
> {
> public int? ID { get; set; }
> public bool? SomeFlag { get; set; }
> public string Key { get; set; }
> // more code
> public void Write(TProtocol oprot) {
> TStruct struc = new TStruct("MyStruct");
> oprot.WriteStructBegin(struc);
> TField field = new TField();
> if (ID != null) {
> field.Name = "ID";
> field.Type = TType.I32;
> field.ID = 1;
> oprot.WriteFieldBegin(field);
> oprot.WriteI32(ID.Value);
> oprot.WriteFieldEnd();
> }
> if (SomeFlag != null) {
> field.Name = "someFlag";
> field.Type = TType.Bool;
> field.ID = 2;
> oprot.WriteFieldBegin(field);
> oprot.WriteBool(SomeFlag.Value);
> oprot.WriteFieldEnd();
> }
> if (Key != null) {
> field.Name = "Key";
> field.Type = TType.String;
> field.ID = 3;
> oprot.WriteFieldBegin(field);
> oprot.WriteString(Key);
> oprot.WriteFieldEnd();
> }
> oprot.WriteFieldStop();
> oprot.WriteStructEnd();
> }
> {code}
> which is unexpected, since the ID field is required and thus there's no need to maintrain the _isset flag for thuis fiel. Expected behaviour would be that
> * the field is always written to the output
> * it is ensured that the field is successfully read from the input (see C++ impl)
--
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