Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5316

Netstd compiler generates wrong ToString() method: .ToString(sb)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 0.14.0
    • 0.14.0
    • netstd - Compiler
    • None

    Description

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

      Test case: 

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

      produces following ToString() method:

          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();
          }
      
      

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

      Full generated class is in attachment

      Attachments

        1. Test.cs
          10 kB
          Konstantin

        Activity

          People

            jensg Jens Geyer
            kpozdniakov Konstantin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: