From af61f0c7c42907e8e303fd0ad0506598aaa40a90 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 8 Apr 2020 22:21:42 +0300 Subject: [PATCH] Fix .NET binding. GitOrigin-RevId: 4e251471a358c4d5546663eca7cd16b91ec2574e --- td/generate/DotnetTlDocumentationGenerator.php | 4 ++-- td/generate/tl_writer_dotnet.h | 7 ++++--- td/tl/tl_dotnet_object.h | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/td/generate/DotnetTlDocumentationGenerator.php b/td/generate/DotnetTlDocumentationGenerator.php index d32492c85..674cbe13a 100644 --- a/td/generate/DotnetTlDocumentationGenerator.php +++ b/td/generate/DotnetTlDocumentationGenerator.php @@ -54,7 +54,7 @@ class DotnetTlDocumentationGenerator extends TlDocumentationGenerator case 'string': return 'String^'; case 'bytes': - return 'Array^'; + return 'Array^'; case 'bool': case 'int': case 'long': @@ -210,7 +210,7 @@ EOT while (substr($field_type, $pos, 6) === 'Array<') { $pos += 6; } - if (substr($field_type, $pos, 6) !== 'String' && ucfirst(substr($field_type, $pos)) === substr($field_type, $pos)) { + if (substr($field_type, $pos, 4) !== 'BYTE' && 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); diff --git a/td/generate/tl_writer_dotnet.h b/td/generate/tl_writer_dotnet.h index 276f4ba30..012958054 100644 --- a/td/generate/tl_writer_dotnet.h +++ b/td/generate/tl_writer_dotnet.h @@ -158,7 +158,7 @@ class TlWriterDotNet : public TL_writer { return "String^"; } if (name == "Bytes") { - return "Array^"; + return "Array^"; } if (name == "Vector") { @@ -288,7 +288,8 @@ class TlWriterDotNet : public TL_writer { while (field_type.substr(pos, 6) == "Array<") { pos += 6; } - if (field_type.substr(pos, 6) != "String" && to_upper(field_type[pos]) == field_type[pos]) { + if (field_type.substr(pos, 4) != "BYTE" && 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); @@ -383,7 +384,7 @@ class TlWriterDotNet : public TL_writer { } else { ss << ", "; } - bool need_bytes = gen_field_type(it) == "Array^" || gen_field_type(it) == "Array^>^"; + bool need_bytes = gen_field_type(it) == "Array^" || gen_field_type(it) == "Array^>^"; ss << (need_bytes ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")"; } ss << ");\n}\n"; diff --git a/td/tl/tl_dotnet_object.h b/td/tl/tl_dotnet_object.h index ea1c83663..a1afce343 100644 --- a/td/tl/tl_dotnet_object.h +++ b/td/tl/tl_dotnet_object.h @@ -63,7 +63,7 @@ inline String^ FromUnmanaged(const std::string &from) { } inline auto CLRCALL BytesFromUnmanaged(const std::string &from) { - Array^ res = REF_NEW Vector(static_cast(from.size())); + Array^ res = REF_NEW Vector(static_cast(from.size())); ArrayIndexType i = 0; for (auto b : from) { ArraySet(res, i++, b); @@ -160,7 +160,7 @@ inline std::string ToUnmanaged(String ^from) { return string_to_unmanaged(from); } -inline std::string ToUnmanaged(Array^ from) { +inline std::string ToUnmanaged(Array^ from) { if (!from) { return std::string(); }