Fix .Net generator.

GitOrigin-RevId: ec7bf9f7ce7f39eda70bfb2cd633f2e984d5ccce
This commit is contained in:
levlam 2019-06-27 02:47:28 +03:00
parent da4dd220b8
commit edf829b2b9
2 changed files with 12 additions and 6 deletions

View File

@ -206,9 +206,12 @@ EOT
$colon = ''; $colon = '';
foreach ($known_fields as $name => $type) { foreach ($known_fields as $name => $type) {
$field_type = $this->getTypeName($type); $field_type = $this->getTypeName($type);
if (substr($field_type, 0, 5) !== 'Array' && substr($field_type, 0, 6) !== 'String' && $pos = 0;
ucfirst($field_type) === $field_type) { while (substr($field_type, $pos, 6) === 'Array<') {
$field_type = '::Telegram::Td::Api::'.$field_type; $pos += 6;
}
if (substr($field_type, $pos, 6) !== 'String' && ucfirst(substr($field_type, $pos)) === substr($field_type, $pos)) {
$field_type = substr($field_type, 0, $pos).'::Telegram::Td::Api::'.substr($field_type, $pos);
} }
$full_constructor .= $colon.$field_type.' '.$this->getParameterName($name, $class_name); $full_constructor .= $colon.$field_type.' '.$this->getParameterName($name, $class_name);
$colon = ', '; $colon = ', ';

View File

@ -284,9 +284,12 @@ class TlWriterDotNet : public TL_writer {
std::stringstream ss; std::stringstream ss;
ss << (field_num == 0 ? "" : ", "); ss << (field_num == 0 ? "" : ", ");
auto field_type = gen_field_type(a); auto field_type = gen_field_type(a);
if (field_type.substr(0, 5) != "Array" && field_type.substr(0, 6) != "String" && auto pos = 0;
to_upper(field_type[0]) == field_type[0]) { while (field_type.substr(pos, 6) == "Array<") {
field_type = "::Telegram::Td::Api::" + field_type; pos += 6;
}
if (field_type.substr(pos, 6) != "String" && to_upper(field_type[pos]) == field_type[pos]) {
field_type = field_type.substr(0, pos) + "::Telegram::Td::Api::" + field_type.substr(pos);
} }
ss << field_type << " " << to_camelCase(a.name); ss << field_type << " " << to_camelCase(a.name);
return ss.str(); return ss.str();