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 5d6fb16..617cbf0 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -464,7 +464,11 @@
}
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 @@
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 @@
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 @@
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();
+ }
}
}