Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
GD0002: Missing partial modifier on declaration of type which contains nested classes that derive from GodotObject¶
Regel-ID |
GD0002 |
Kategorie |
Verwendung |
Breaking- oder nicht-Breaking-Fix |
Non-breaking |
Standardmäßig aktiviert |
Ja |
Ursache¶
A type that derives from GodotObject
is contained in a non-partial type declaration.
Beschreibung der Regel¶
Godot source generators add generated code to user-defined types to implement the integration with the engine. Source generators can't add generated code to types that aren't declared partial.
public class InvalidParentType
{
// MyNode is contained in a non-partial type so the source generators
// can't enhance this type to work with Godot.
public partial class MyNode : Node { }
}
public partial class ValidParentType
{
// MyNode is contained in a partial type so the source generators
// can enhance this type to work with Godot.
public partial class MyNode : Node { }
}
Wie man Verstöße behebt¶
To fix a violation of this rule, add the partial
keyword to the type
declaration.
Wann Warnungen unterdrückt werden sollten¶
Do not suppress a warning from this rule. Types that derive from GodotObject
but aren't partial can't be enhanced by the source generators, resulting in
unexpected runtime errors.