From 3dd02144d5d0b0b3cc1f95856ecd22c2516f45e3 Mon Sep 17 00:00:00 2001 From: tira-misu Date: Mon, 26 Jul 2021 19:02:27 +0200 Subject: [PATCH] [C#] Fix field name struct name collision (#6744) (#6757) * Fix C/C++ CreateDirect with sorted vectors If a struct has a key the vector has to be sorted. To sort the vector you can't use "const". * Changes due to code review * Improve code readability * Add generate of JSON schema to string to lib * option indent_step is supported * Remove unused variables * Fix break in test * Fix style to be consistent with rest of the code * [C#] Fix field name struct name collision (#6744) --- src/idl_gen_csharp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/idl_gen_csharp.cpp b/src/idl_gen_csharp.cpp index 3783c89dd..b0fc81b01 100644 --- a/src/idl_gen_csharp.cpp +++ b/src/idl_gen_csharp.cpp @@ -619,6 +619,7 @@ class CSharpGenerator : public BaseGenerator { std::string dest_cast = DestinationCast(field.value.type); std::string src_cast = SourceCast(field.value.type); std::string field_name_camel = MakeCamel(field.name, true); + if (field_name_camel == struct_def.name) { field_name_camel += "_"; } std::string method_start = " public " + type_name_dest + optional + " " + field_name_camel; std::string obj = "(new " + type_name + "())";