diff options
author | Aleks Rutins <aleks@rutins.com> | 2023-03-03 18:25:15 -0500 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-13 21:52:44 +0100 |
commit | 782e1fe84e10ab38b57479d149a48b255493609f (patch) | |
tree | 51c6123b10765f81d71ba3fcce2c0e14a321667d /modules | |
parent | 01324f025ae4dbc64bbaf42fe5f6fc0ab9745998 (diff) |
Validate that C# class names are valid identifiers
(cherry picked from commit ae8752a731ed0b1c9307bfc5ae817e917a887294)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mono/csharp_script.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index aad8ab9a57..1dbf6b3471 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -57,6 +57,7 @@ #include "godotsharp_dirs.h" #include "managed_callable.h" #include "mono_gd/gd_mono_cache.h" +#include "servers/text_server.h" #include "signal_awaiter_utils.h" #include "utils/macros.h" #include "utils/naming_utils.h" @@ -366,6 +367,10 @@ String CSharpLanguage::validate_path(const String &p_path) const { if (keywords.find(class_name)) { return RTR("Class name can't be a reserved keyword"); } + if (!TS->is_valid_identifier(class_name)) { + return RTR("Class name must be a valid identifier"); + } + return ""; } |