C#: Added <autogenerated> in cs generator file header comment (#4291)

* Added <autogenerated> in cs generator file header comment
#4287

* CS: Added xml-correct file header comment including "<auto-generated>...</auto-generated>"
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
This commit is contained in:
schoetbi 2017-05-16 23:28:34 +02:00 committed by Wouter van Oortmerssen
parent 90daabd5b1
commit 0f5f7faa9f
23 changed files with 59 additions and 23 deletions

View File

@ -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,

View File

@ -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;

View File

@ -20,7 +20,6 @@
#include "flatbuffers/idl.h"
#include "flatbuffers/util.h"
#include "flatbuffers/code_generators.h"
#include <algorithm>
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 = "// <auto-generated>\n"
"// " + std::string(FlatBuffersGeneratedWarning()) + "\n"
"// </auto-generated>\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;

View File

@ -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";

View File

@ -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);

View File

@ -66,7 +66,7 @@ namespace php {
const bool needs_imports, std::string *code_ptr) {
std::string &code = *code_ptr;
code += "<?php\n";
code = code + "// " + FlatBuffersGeneratedWarning();
code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n";
code += "namespace " + name_space_name + ";\n\n";
if (needs_imports) {

View File

@ -630,7 +630,7 @@ class PythonGenerator : 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 += "# namespace: " + name_space_name + "\n\n";
if (needs_imports) {
code += "import flatbuffers\n\n";

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace MyGame.Example2
{

Binary file not shown.

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA.NamespaceB
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA.NamespaceB
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA.NamespaceB
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA
{

View File

@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
// <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceC
{