GD0002.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. GD0002: Missing partial modifier on declaration of type which contains nested classes that derive from GodotObject
  2. ==================================================================================================================
  3. ==================================== ======================================
  4. Value
  5. ==================================== ======================================
  6. **Rule ID** GD0002
  7. **Category** Usage
  8. **Fix is breaking or non-breaking** Non-breaking
  9. **Enabled by default** Yes
  10. ==================================== ======================================
  11. Cause
  12. -----
  13. A type that derives from ``GodotObject`` is contained in a non-partial type declaration.
  14. Rule description
  15. ----------------
  16. Godot source generators add generated code to user-defined types to implement
  17. the integration with the engine. Source generators can't add generated code to
  18. types that aren't declared partial.
  19. .. code-block:: csharp
  20. public class InvalidParentType
  21. {
  22. // MyNode is contained in a non-partial type so the source generators
  23. // can't enhance this type to work with Godot.
  24. public partial class MyNode : Node { }
  25. }
  26. public partial class ValidParentType
  27. {
  28. // MyNode is contained in a partial type so the source generators
  29. // can enhance this type to work with Godot.
  30. public partial class MyNode : Node { }
  31. }
  32. How to fix violations
  33. ---------------------
  34. To fix a violation of this rule, add the ``partial`` keyword to the type
  35. declaration.
  36. When to suppress warnings
  37. -------------------------
  38. Do not suppress a warning from this rule. Types that derive from ``GodotObject``
  39. but aren't partial can't be enhanced by the source generators, resulting in
  40. unexpected runtime errors.