[
https://issues.apache.org/jira/browse/THRIFT-5040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Konstantin updated THRIFT-5040:
-------------------------------
Description:
Optional fields for value types are not Nullable in C# (netstd)
for example
{code:java}
struct Test {
1: required i64 id,
2: optional bool some_flag
}
{code}
will generate class
{code:java}
public partial class Test : TBase{
private bool _some_flag;
public long Id { get; set; }
public bool Some_flag { get { return _some_flag; } set {
__isset.some_flag = true; this._some_flag = value; } }
{code}
that makes the some_flag to be false even if it was not set on the sending
party.
The optional value types should be generated as Nullable<T>:
{code:java}
private bool? _some_flag;
{code}
This is especially harmful with other value types
was:
Optional fields for struct types are not Nullable in C# (netstd)
for example
{code:java}
struct Test {
1: required i64 id,
2: optional bool some_flag
}
{code}
will generate class
{code:java}
public partial class Test : TBase{
private bool _some_flag;
public long Id { get; set; }
public bool Some_flag { get { return _some_flag; } set {
__isset.some_flag = true; this._some_flag = value; } }
{code}
that makes the some_flag to be false even if it was not set on the sending
party.
The optional struct types should be generated as Nullable<T>:
{code:java}
private bool? _some_flag;
{code}
> Optional fields for struct types are not Nullable in C# (netstd)
> ----------------------------------------------------------------
>
> Key: THRIFT-5040
> URL: https://issues.apache.org/jira/browse/THRIFT-5040
> Project: Thrift
> Issue Type: Bug
> Components: netstd - Compiler
> Affects Versions: 0.13.0
> Reporter: Konstantin
> Priority: Major
>
> Optional fields for value types are not Nullable in C# (netstd)
> for example
> {code:java}
> struct Test {
> 1: required i64 id,
> 2: optional bool some_flag
> }
> {code}
> will generate class
> {code:java}
> public partial class Test : TBase{
> private bool _some_flag;
> public long Id { get; set; }
> public bool Some_flag { get { return _some_flag; } set
> { __isset.some_flag = true; this._some_flag = value; } }
> {code}
> that makes the some_flag to be false even if it was not set on the sending
> party.
>
> The optional value types should be generated as Nullable<T>:
> {code:java}
> private bool? _some_flag;
> {code}
>
> This is especially harmful with other value types
--
This message was sent by Atlassian Jira
(v8.3.4#803005)