Commit 0f5f7faa authored by schoetbi's avatar schoetbi Committed by Wouter van Oortmerssen

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
parent 90daabd5
...@@ -68,7 +68,7 @@ void CodeWriter::operator+=(std::string text) { ...@@ -68,7 +68,7 @@ void CodeWriter::operator+=(std::string text) {
const char *BaseGenerator::FlatBuffersGeneratedWarning() { const char *BaseGenerator::FlatBuffersGeneratedWarning() {
return "automatically generated by the FlatBuffers compiler," return "automatically generated by the FlatBuffers compiler,"
" do not modify\n\n"; " do not modify";
} }
std::string BaseGenerator::NamespaceDir(const Parser &parser, std::string BaseGenerator::NamespaceDir(const Parser &parser,
......
...@@ -88,7 +88,7 @@ class CppGenerator : public BaseGenerator { ...@@ -88,7 +88,7 @@ class CppGenerator : public BaseGenerator {
// structs, and tables) and output them to a single file. // structs, and tables) and output them to a single file.
bool generate() { bool generate() {
code_.Clear(); code_.Clear();
code_ += "// " + std::string(FlatBuffersGeneratedWarning()); code_ += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
const auto include_guard = GenIncludeGuard(); const auto include_guard = GenIncludeGuard();
code_ += "#ifndef " + include_guard; code_ += "#ifndef " + include_guard;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "flatbuffers/idl.h" #include "flatbuffers/idl.h"
#include "flatbuffers/util.h" #include "flatbuffers/util.h"
#include "flatbuffers/code_generators.h" #include "flatbuffers/code_generators.h"
#include <algorithm>
namespace flatbuffers { namespace flatbuffers {
...@@ -204,7 +203,14 @@ class GeneralGenerator : public BaseGenerator { ...@@ -204,7 +203,14 @@ class GeneralGenerator : public BaseGenerator {
if (!classcode.length()) return true; if (!classcode.length()) return true;
std::string code; 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); std::string namespace_name = FullNamespace(".", ns);
if (!namespace_name.empty()) { if (!namespace_name.empty()) {
code += lang_.namespace_ident + namespace_name + lang_.namespace_begin; code += lang_.namespace_ident + namespace_name + lang_.namespace_begin;
......
...@@ -773,7 +773,7 @@ class GoGenerator : public BaseGenerator { ...@@ -773,7 +773,7 @@ class GoGenerator : public BaseGenerator {
void BeginFile(const std::string name_space_name, const bool needs_imports, void BeginFile(const std::string name_space_name, const bool needs_imports,
std::string *code_ptr) { std::string *code_ptr) {
std::string &code = *code_ptr; std::string &code = *code_ptr;
code = code + "// " + FlatBuffersGeneratedWarning(); code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n";
code += "package " + name_space_name + "\n\n"; code += "package " + name_space_name + "\n\n";
if (needs_imports) { if (needs_imports) {
code += "import (\n"; code += "import (\n";
......
...@@ -92,7 +92,7 @@ class JsGenerator : public BaseGenerator { ...@@ -92,7 +92,7 @@ class JsGenerator : public BaseGenerator {
generateImportDependencies(&import_code, imported_files); generateImportDependencies(&import_code, imported_files);
generateReexports(&import_code, reexports, imported_files); generateReexports(&import_code, reexports, imported_files);
code = code + "// " + FlatBuffersGeneratedWarning(); code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n";
// Generate code for all the namespace declarations. // Generate code for all the namespace declarations.
GenNamespaces(&code, &exports_code); GenNamespaces(&code, &exports_code);
......
...@@ -66,7 +66,7 @@ namespace php { ...@@ -66,7 +66,7 @@ namespace php {
const bool needs_imports, std::string *code_ptr) { const bool needs_imports, std::string *code_ptr) {
std::string &code = *code_ptr; std::string &code = *code_ptr;
code += "<?php\n"; code += "<?php\n";
code = code + "// " + FlatBuffersGeneratedWarning(); code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n";
code += "namespace " + name_space_name + ";\n\n"; code += "namespace " + name_space_name + ";\n\n";
if (needs_imports) { if (needs_imports) {
......
...@@ -630,7 +630,7 @@ class PythonGenerator : public BaseGenerator { ...@@ -630,7 +630,7 @@ class PythonGenerator : public BaseGenerator {
void BeginFile(const std::string name_space_name, const bool needs_imports, void BeginFile(const std::string name_space_name, const bool needs_imports,
std::string *code_ptr) { std::string *code_ptr) {
std::string &code = *code_ptr; std::string &code = *code_ptr;
code = code + "# " + FlatBuffersGeneratedWarning(); code = code + "# " + FlatBuffersGeneratedWarning() + "\n\n";
code += "# namespace: " + name_space_name + "\n\n"; code += "# namespace: " + name_space_name + "\n\n";
if (needs_imports) { if (needs_imports) {
code += "import flatbuffers\n\n"; code += "import flatbuffers\n\n";
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example
{ {
......
// 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 namespace MyGame.Example2
{ {
......
No preview for this file type
// 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 namespace NamespaceA.NamespaceB
{ {
......
// 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 namespace NamespaceA.NamespaceB
{ {
......
// 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 namespace NamespaceA.NamespaceB
{ {
......
// automatically generated by the FlatBuffers compiler, do not modify // <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA namespace NamespaceA
{ {
......
// automatically generated by the FlatBuffers compiler, do not modify // <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceA namespace NamespaceA
{ {
......
// automatically generated by the FlatBuffers compiler, do not modify // <auto-generated>
// automatically generated by the FlatBuffers compiler, do not modify
// </auto-generated>
namespace NamespaceC namespace NamespaceC
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment