From 0f5f7faa9fcf034d1189653f1b6e32b245a7f8a1 Mon Sep 17 00:00:00 2001 From: schoetbi Date: Tue, 16 May 2017 23:28:34 +0200 Subject: [PATCH] C#: Added in cs generator file header comment (#4291) * Added in cs generator file header comment #4287 * CS: Added xml-correct file header comment including "..." code_generators.cpp: FlatBuffersGeneratedWarning() function replaced by compile time constant "GeneratedWarning" also removed extra newlines at end of GeneratedWarning to be able to generate a xml well formed file comment for cs files #4291 * code_generators: Changed static string GeneratedWarning back to function FlatBuffersGeneratedWarning() #4291 * Added modified Unit-Test files #4291 * idl_gen_general: Add autogenerated only in C# code #4291 --- src/code_generators.cpp | 2 +- src/idl_gen_cpp.cpp | 2 +- src/idl_gen_general.cpp | 10 ++++++++-- src/idl_gen_go.cpp | 2 +- src/idl_gen_js.cpp | 2 +- src/idl_gen_php.cpp | 2 +- src/idl_gen_python.cpp | 2 +- tests/MyGame/Example/Ability.cs | 4 +++- tests/MyGame/Example/Any.cs | 4 +++- tests/MyGame/Example/Color.cs | 4 +++- tests/MyGame/Example/Monster.cs | 4 +++- tests/MyGame/Example/Stat.cs | 4 +++- tests/MyGame/Example/Test.cs | 4 +++- .../MyGame/Example/TestSimpleTableWithEnum.cs | 4 +++- tests/MyGame/Example/Vec3.cs | 4 +++- tests/MyGame/Example2/Monster.cs | 4 +++- tests/monster_test.bfbs | Bin 4288 -> 3696 bytes .../NamespaceA/NamespaceB/EnumInNestedNS.cs | 4 +++- .../NamespaceA/NamespaceB/StructInNestedNS.cs | 4 +++- .../NamespaceA/NamespaceB/TableInNestedNS.cs | 4 +++- .../NamespaceA/SecondTableInA.cs | 4 +++- .../NamespaceA/TableInFirstNS.cs | 4 +++- tests/namespace_test/NamespaceC/TableInC.cs | 4 +++- 23 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/code_generators.cpp b/src/code_generators.cpp index 7838cedfd..3126ce59d 100644 --- a/src/code_generators.cpp +++ b/src/code_generators.cpp @@ -68,7 +68,7 @@ void CodeWriter::operator+=(std::string text) { const char *BaseGenerator::FlatBuffersGeneratedWarning() { return "automatically generated by the FlatBuffers compiler," - " do not modify\n\n"; + " do not modify"; } std::string BaseGenerator::NamespaceDir(const Parser &parser, diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 169acd585..378990448 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -88,7 +88,7 @@ class CppGenerator : public BaseGenerator { // structs, and tables) and output them to a single file. bool generate() { code_.Clear(); - code_ += "// " + std::string(FlatBuffersGeneratedWarning()); + code_ += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; const auto include_guard = GenIncludeGuard(); code_ += "#ifndef " + include_guard; diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp index 248d57d65..ad91cbe0f 100644 --- a/src/idl_gen_general.cpp +++ b/src/idl_gen_general.cpp @@ -20,7 +20,6 @@ #include "flatbuffers/idl.h" #include "flatbuffers/util.h" #include "flatbuffers/code_generators.h" -#include namespace flatbuffers { @@ -204,7 +203,14 @@ class GeneralGenerator : public BaseGenerator { if (!classcode.length()) return true; std::string code; - code = code + "// " + FlatBuffersGeneratedWarning(); + if (lang_.language == IDLOptions::kCSharp) { + code = "// \n" + "// " + std::string(FlatBuffersGeneratedWarning()) + "\n" + "// \n\n"; + } else { + code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; + } + std::string namespace_name = FullNamespace(".", ns); if (!namespace_name.empty()) { code += lang_.namespace_ident + namespace_name + lang_.namespace_begin; diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp index 58a60aae6..4cdbf03c1 100644 --- a/src/idl_gen_go.cpp +++ b/src/idl_gen_go.cpp @@ -773,7 +773,7 @@ class GoGenerator : public BaseGenerator { void BeginFile(const std::string name_space_name, const bool needs_imports, std::string *code_ptr) { std::string &code = *code_ptr; - code = code + "// " + FlatBuffersGeneratedWarning(); + code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n"; code += "package " + name_space_name + "\n\n"; if (needs_imports) { code += "import (\n"; diff --git a/src/idl_gen_js.cpp b/src/idl_gen_js.cpp index a07d5f116..edcb780f0 100644 --- a/src/idl_gen_js.cpp +++ b/src/idl_gen_js.cpp @@ -92,7 +92,7 @@ class JsGenerator : public BaseGenerator { generateImportDependencies(&import_code, imported_files); generateReexports(&import_code, reexports, imported_files); - code = code + "// " + FlatBuffersGeneratedWarning(); + code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n"; // Generate code for all the namespace declarations. GenNamespaces(&code, &exports_code); diff --git a/src/idl_gen_php.cpp b/src/idl_gen_php.cpp index a893f98bf..7266551f6 100644 --- a/src/idl_gen_php.cpp +++ b/src/idl_gen_php.cpp @@ -66,7 +66,7 @@ namespace php { const bool needs_imports, std::string *code_ptr) { std::string &code = *code_ptr; code += " +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Any.cs b/tests/MyGame/Example/Any.cs index 8fdc2fca1..8393853b0 100644 --- a/tests/MyGame/Example/Any.cs +++ b/tests/MyGame/Example/Any.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Color.cs b/tests/MyGame/Example/Color.cs index 625d040a9..f40d60ba7 100644 --- a/tests/MyGame/Example/Color.cs +++ b/tests/MyGame/Example/Color.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Monster.cs b/tests/MyGame/Example/Monster.cs index 6eee25dc9..ab4cdfe8a 100644 --- a/tests/MyGame/Example/Monster.cs +++ b/tests/MyGame/Example/Monster.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Stat.cs b/tests/MyGame/Example/Stat.cs index 1ea805016..e1fd572ed 100644 --- a/tests/MyGame/Example/Stat.cs +++ b/tests/MyGame/Example/Stat.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Test.cs b/tests/MyGame/Example/Test.cs index 406f5f137..184213160 100644 --- a/tests/MyGame/Example/Test.cs +++ b/tests/MyGame/Example/Test.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.cs b/tests/MyGame/Example/TestSimpleTableWithEnum.cs index 3d2a3f443..f24d6eac7 100644 --- a/tests/MyGame/Example/TestSimpleTableWithEnum.cs +++ b/tests/MyGame/Example/TestSimpleTableWithEnum.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example/Vec3.cs b/tests/MyGame/Example/Vec3.cs index 6ea4b0ee7..e1669f9bb 100644 --- a/tests/MyGame/Example/Vec3.cs +++ b/tests/MyGame/Example/Vec3.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example { diff --git a/tests/MyGame/Example2/Monster.cs b/tests/MyGame/Example2/Monster.cs index 406c4bd87..e880ebbed 100644 --- a/tests/MyGame/Example2/Monster.cs +++ b/tests/MyGame/Example2/Monster.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace MyGame.Example2 { diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index 78871d504af00b89b914a99875abdce6801b38b7..b91ff4db6e47c2fdbb5eb1ae117ee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*1a*Z7*EDNzr27j2|2lSlO+!g$r##p_QlftS8myU0(wmhb^I zXzbGZ%6Rl9G8IU$HWQDuZytQ32Y5%S5gT`K!v6`}dNRg;( z=#PLl*qb?TaTHNC`!a=|K0g560(}5tdkUFbU>kLFoo9{v#M&~7{<79DY1E>e|6=3YC9 zo_lPYIUD>*;yu8;uys)yvE1&(r1u diff --git a/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs index 5f979fe54..1a75ed432 100644 --- a/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs +++ b/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceA.NamespaceB { diff --git a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs index bb627ad32..397fb89f5 100644 --- a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs +++ b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceA.NamespaceB { diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs index c33d1fbca..892174496 100644 --- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs +++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceA.NamespaceB { diff --git a/tests/namespace_test/NamespaceA/SecondTableInA.cs b/tests/namespace_test/NamespaceA/SecondTableInA.cs index f28ed8604..99c82ccb1 100644 --- a/tests/namespace_test/NamespaceA/SecondTableInA.cs +++ b/tests/namespace_test/NamespaceA/SecondTableInA.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceA { diff --git a/tests/namespace_test/NamespaceA/TableInFirstNS.cs b/tests/namespace_test/NamespaceA/TableInFirstNS.cs index 20f4b4be3..48b5b205a 100644 --- a/tests/namespace_test/NamespaceA/TableInFirstNS.cs +++ b/tests/namespace_test/NamespaceA/TableInFirstNS.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceA { diff --git a/tests/namespace_test/NamespaceC/TableInC.cs b/tests/namespace_test/NamespaceC/TableInC.cs index c7f2c8a78..0c454acb5 100644 --- a/tests/namespace_test/NamespaceC/TableInC.cs +++ b/tests/namespace_test/NamespaceC/TableInC.cs @@ -1,4 +1,6 @@ -// automatically generated by the FlatBuffers compiler, do not modify +// +// automatically generated by the FlatBuffers compiler, do not modify +// namespace NamespaceC {