File tree 1 file changed +49
-0
lines changed
tutorials/scripting/c_sharp/diagnostics
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ GD0003: Found multiple classes with the same name in the same script file
2
+ =========================================================================
3
+
4
+ ==================================== ======================================
5
+ Value
6
+ ==================================== ======================================
7
+ **Rule ID ** GD0003
8
+ **Category ** Usage
9
+ **Fix is breaking or non-breaking ** Non-breaking
10
+ **Enabled by default ** Yes
11
+ ==================================== ======================================
12
+
13
+ Cause
14
+ -----
15
+
16
+ A script file contains multiple types that derives from ``GodotObject `` with
17
+ a name that matches the script file. Only one type in the script file should
18
+ match the file name.
19
+
20
+ Rule description
21
+ ----------------
22
+
23
+ Godot requires scripts to have a unique path so every type must be defined on its
24
+ own file and the type name must match the file name.
25
+
26
+ .. code-block :: csharp
27
+
28
+ public partial class MyNode : Node { }
29
+
30
+ namespace DifferentNamespace
31
+ {
32
+ // Invalid because there's already a type with the name MyNode in this file.
33
+ public partial class MyNode : Node { }
34
+ }
35
+
36
+ // Invalid because there's already a type with the name MyNode in this file.
37
+ public partial class MyNode <T > : Node { }
38
+
39
+ How to fix violations
40
+ ---------------------
41
+
42
+ To fix a violation of this rule, move each type declaration to a different file.
43
+
44
+ When to suppress warnings
45
+ -------------------------
46
+
47
+ Do not suppress a warning from this rule. Types that derive from ``GodotObject ``
48
+ must have a unique path otherwise the engine can't load the script by path,
49
+ resulting in unexpected runtime errors.
You can’t perform that action at this time.
0 commit comments