thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantin (Jira)" <j...@apache.org>
Subject [jira] [Created] (THRIFT-5316) Netstd compiler generates wrong ToString() method: .ToString(sb)
Date Mon, 23 Nov 2020 10:19:00 GMT
Konstantin created THRIFT-5316:
----------------------------------

             Summary: Netstd compiler generates wrong ToString() method: .ToString(sb) 
                 Key: THRIFT-5316
                 URL: https://issues.apache.org/jira/browse/THRIFT-5316
             Project: Thrift
          Issue Type: Bug
          Components: netstd - Compiler
    Affects Versions: 0.14.0
            Reporter: Konstantin


Thrift compiler generate code that doesn't compile netstd: object doesn't have ToString(StringBuilder)
overload. 

Test case: 

{code:thrift}
struct Test {
  1: string test_string
  2: i64 test_i64
  3: binary test_binary
  4: map<string, string> test_map
} 
{code}

produces following ToString() method:

{code:csharp}
    public override string ToString()
    {
      var sb = new StringBuilder("Test(");
      int tmp6 = 0;
      if((Test_string != null) && __isset.test_string)
      {
        if(0 < tmp6++) { sb.Append(", "); }
        sb.Append("Test_string: ");
        Test_string.ToString(sb);
      }
      if(__isset.test_i64)
      {
        if(0 < tmp6++) { sb.Append(", "); }
        sb.Append("Test_i64: ");
        Test_i64.ToString(sb);
      }
      if((Test_binary != null) && __isset.test_binary)
      {
        if(0 < tmp6++) { sb.Append(", "); }
        sb.Append("Test_binary: ");
        Test_binary.ToString(sb);
      }
      if((Test_map != null) && __isset.test_map)
      {
        if(0 < tmp6++) { sb.Append(", "); }
        sb.Append("Test_map: ");
        Test_map.ToString(sb);
      }
      sb.Append(")");
      return sb.ToString();
    }

{code}

Test_string.ToString(sb); (and folllowing .ToString(sb)) - produces  build failure:  [CS1503]
Argument 1: cannot convert from 'System.Text.StringBuilder' to 'System.IFormatProvider?'
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message