[C#] Respect command line parameter for file name extension and suffix (#6779)

* Make CSharp use the command line parameter for file name extension and suffix

* Default file name now has _generated in it,
so we need to rename all the generated test files

tests/namespace_test/NamespaceA/TableInC.* are no
longer used, so these can be deleted

* Fix C# testing projects so that they reference
the new _generated.cs files

* Revert "Fix C# testing projects so that they reference"

This reverts commit cf62b9c5d4.

* Revert "Default file name now has _generated in it,"

This reverts commit 042aa81f10.

* Revert "Make CSharp use the command line parameter for file name extension and suffix"

This reverts commit ba8cd06646.

* Make CSharp use the command line parameter for file name extension and suffix

* Fixup clang tidy

* Fix more clang-tidy
This commit is contained in:
Todd Hansen 2021-08-15 14:51:58 -05:00 committed by GitHub
parent f20d2253ae
commit 2ca5f0e72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -65,7 +65,7 @@ class CSharpGenerator : public BaseGenerator {
one_file_code += enumcode; one_file_code += enumcode;
} else { } else {
if (!SaveType(enum_def.name, *enum_def.defined_namespace, enumcode, if (!SaveType(enum_def.name, *enum_def.defined_namespace, enumcode,
false)) false, parser_.opts))
return false; return false;
} }
} }
@ -81,14 +81,14 @@ class CSharpGenerator : public BaseGenerator {
one_file_code += declcode; one_file_code += declcode;
} else { } else {
if (!SaveType(struct_def.name, *struct_def.defined_namespace, declcode, if (!SaveType(struct_def.name, *struct_def.defined_namespace, declcode,
true)) true, parser_.opts))
return false; return false;
} }
} }
if (parser_.opts.one_file) { if (parser_.opts.one_file) {
return SaveType(file_name_, *parser_.current_namespace_, one_file_code, return SaveType(file_name_, *parser_.current_namespace_, one_file_code,
true); true, parser_.opts);
} }
return true; return true;
} }
@ -96,7 +96,8 @@ class CSharpGenerator : public BaseGenerator {
// Save out the generated code for a single class while adding // Save out the generated code for a single class while adding
// declaration boilerplate. // declaration boilerplate.
bool SaveType(const std::string &defname, const Namespace &ns, bool SaveType(const std::string &defname, const Namespace &ns,
const std::string &classcode, bool needs_includes) const { const std::string &classcode, bool needs_includes,
const IDLOptions &options) const {
if (!classcode.length()) return true; if (!classcode.length()) return true;
std::string code = std::string code =
@ -117,7 +118,10 @@ class CSharpGenerator : public BaseGenerator {
} }
code += classcode; code += classcode;
if (!namespace_name.empty()) { code += "\n}\n"; } if (!namespace_name.empty()) { code += "\n}\n"; }
auto filename = NamespaceDir(ns) + defname + ".cs"; auto filename = NamespaceDir(ns) + defname;
if (options.one_file) { filename += options.filename_suffix; }
filename +=
options.filename_extension.empty() ? ".cs" : options.filename_extension;
return SaveFile(filename.c_str(), code, false); return SaveFile(filename.c_str(), code, false);
} }