Added support for C# partial class generation when the csharp_partial attribute is used on a table/struct.

This commit is contained in:
Oli Wilkinson
2016-01-21 15:30:13 +00:00
parent 491e970943
commit dbf6702371
4 changed files with 12 additions and 3 deletions

View File

@@ -659,7 +659,15 @@ static void GenStruct(const LanguageParameters &lang, const Parser &parser,
// int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default;
// }
GenComment(struct_def.doc_comment, code_ptr, &lang.comment_config);
code += std::string("public ") + lang.unsubclassable_decl;
code += "public ";
if (lang.language == IDLOptions::kCSharp &&
struct_def.attributes.Lookup("csharp_partial")) {
// generate a partial class for this C# struct/table
code += "partial ";
}
else {
code += lang.unsubclassable_decl;
}
code += "class " + struct_def.name + lang.inheritance_marker;
code += struct_def.fixed ? "Struct" : "Table";
code += " {\n";