From: ra Date: Fri, 30 May 2014 13:31:00 +0000 (-0700) Subject: THRIFT-2558: CSharp gen tries to add str + int X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=91b3b1a6b204b381d6ccea1016b6900667ac1a6c;p=common%2Fthrift.git THRIFT-2558: CSharp gen tries to add str + int Client: C# Compiler Patch: Randy Abernethy The C# generator attempts to throw a str + int string in several places producing undesirable results. This patch uses stringstream to concatenate the string representations. --- diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc index 5d6fb16f..617cbf03 100644 --- a/compiler/cpp/src/generate/t_csharp_generator.cc +++ b/compiler/cpp/src/generate/t_csharp_generator.cc @@ -464,7 +464,11 @@ std::string t_csharp_generator::render_const_value(ofstream& out, string name, t } break; default: - throw "compiler error: no const of base type " + tbase; + { + std::stringstream ss; + ss << "compiler error: no const of base type " << tbase; + throw ss.str(); + } } } else if (type->is_enum()) { render << type->get_name() << "." << value->get_identifier_name(); @@ -2034,7 +2038,11 @@ void t_csharp_generator::generate_deserialize_field(ofstream& out, t_field* tfie out << "ReadDouble();"; break; default: - throw "compiler error: no C# name for base type " + tbase; + { + std::stringstream ss; + ss << "compiler error: no C# name for base type " << tbase; + throw ss.str(); + } } } else if (type->is_enum()) { out << "ReadI32();"; @@ -2209,7 +2217,11 @@ void t_csharp_generator::generate_deserialize_list_element(ofstream& out, t_list out << "WriteDouble(" << nullable_name << ");"; break; default: - throw "compiler error: no C# name for base type " + tbase; + { + std::stringstream ss; + ss << "compiler error: no C# name for base type " << tbase; + throw ss.str(); + } } } else if (type->is_enum()) { out << "WriteI32((int)" << nullable_name << ");"; @@ -2453,7 +2465,11 @@ string t_csharp_generator::base_type_name(t_base_type* tbase, bool in_container, case t_base_type::TYPE_DOUBLE: return "double" + postfix; default: - throw "compiler error: no C# name for base type " + tbase->get_base(); + { + std::stringstream ss; + ss << "compiler error: no C# name for base type " << tbase->get_base(); + throw ss.str(); + } } }