Browse Source

Merge pull request #74330 from aleksrutins/csharp-identifier-validation

Ensure that C# script names (and therefore class names) are valid identifiers
Rémi Verschelde 2 năm trước cách đây
mục cha
commit
b2622218f9
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      modules/mono/csharp_script.cpp

+ 5 - 0
modules/mono/csharp_script.cpp

@@ -58,6 +58,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"
@@ -374,6 +375,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 "";
 }