Skip to content

Commit 455b627

Browse files
committed
C#: Add documentation for diagnostic GD0003
1 parent ec3e094 commit 455b627

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.

0 commit comments

Comments
 (0)