|
| 1 | +GD0002: Missing partial modifier on declaration of type which contains one or more subclasses of GodotObject |
| 2 | +============================================================================================================ |
| 3 | + |
| 4 | +==================================== ====================================== |
| 5 | + Value |
| 6 | +==================================== ====================================== |
| 7 | +**Rule ID** GD0002 |
| 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 type that derives from ``GodotObject`` is contained in a non-partial type declaration. |
| 17 | + |
| 18 | +Rule description |
| 19 | +---------------- |
| 20 | + |
| 21 | +Godot source generators add generated code to user-defined types to implement |
| 22 | +the integration with the engine. Source generators can't add generated code to |
| 23 | +types that aren't declared partial. |
| 24 | + |
| 25 | +.. code-block:: csharp |
| 26 | +
|
| 27 | + public class InvalidParentType |
| 28 | + { |
| 29 | + // MyNode is contained in a non-partial type so the source generators |
| 30 | + // can't enhance this type to work with Godot. |
| 31 | + public partial class MyNode : Node { } |
| 32 | + } |
| 33 | +
|
| 34 | + public partial class ValidParentType |
| 35 | + { |
| 36 | + // MyNode is contained in a partial type so the source generators |
| 37 | + // can enhance this type to work with Godot. |
| 38 | + public partial class MyNode : Node { } |
| 39 | + } |
| 40 | +
|
| 41 | +How to fix violations |
| 42 | +--------------------- |
| 43 | + |
| 44 | +To fix a violation of this rule, add the ``partial`` keyword to the type |
| 45 | +declaration. |
| 46 | + |
| 47 | +When to suppress warnings |
| 48 | +------------------------- |
| 49 | + |
| 50 | +Do not suppress a warning from this rule. Types that derive from ``GodotObject`` |
| 51 | +but aren't partial can't be enhanced by the source generators, resulting in |
| 52 | +unexpected runtime errors. |
0 commit comments