GD0102.rst 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. GD0102: The type of the exported member is not supported
  2. ========================================================
  3. ==================================== ======================================
  4. Value
  5. ==================================== ======================================
  6. **Rule ID** GD0102
  7. **Category** Usage
  8. **Fix is breaking or non-breaking** Breaking - If the member type is changed
  9. Non-breaking - If the ``[Export]`` attribute is removed
  10. **Enabled by default** Yes
  11. ==================================== ======================================
  12. Cause
  13. -----
  14. An unsupported type is specified for a member annotated with the ``[Export]``
  15. attribute when a :ref:`Variant-compatible <doc_c_sharp_variant>` type is expected.
  16. Rule description
  17. ----------------
  18. Every exported member must be Variant-compatible so it can be marshalled by
  19. the engine.
  20. .. code-block:: csharp
  21. class SomeType { }
  22. // SomeType is not a valid member type because it doesn't derive from GodotObject,
  23. // so it's not compatible with Variant.
  24. [Export]
  25. public SomeType InvalidProperty { get; set; }
  26. // System.Int32 is a valid type because it's compatible with Variant.
  27. [Export]
  28. public int ValidProperty { get; set; }
  29. How to fix violations
  30. ---------------------
  31. To fix a violation of this rule, change the member's type to be Variant-compatible
  32. or remove the ``[Export]`` attribute.
  33. When to suppress warnings
  34. -------------------------
  35. Do not suppress a warning from this rule. Members with types that can't be marshalled
  36. will result in runtime errors.