From 6472d8c7d4db3aed63af028f227a97001f4b861f Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Fri, 9 Mar 2018 23:34:32 +0100 Subject: Mono: Avoid invalid class names. Disallow reserved keywords as class names and prefix base class with the Godot namespace if it's the same as the class name. Fixes #12483 (cherry picked from commit 700d07cf7cae4e28de107e0c274b27c857d98450) --- modules/mono/csharp_script.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'modules/mono/csharp_script.cpp') diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 525b918b1..1d0afa7f2 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -282,6 +282,15 @@ void CSharpLanguage::get_string_delimiters(List *p_delimiters) const { p_delimiters->push_back("@\" \""); // verbatim string literal } +static String get_base_class_name(const String &p_base_class_name, const String p_class_name) { + + String base_class = p_base_class_name; + if (p_class_name == base_class) { + base_class = "Godot." + base_class; + } + return base_class; +} + Ref