GD0102.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  16. :ref:`Variant-compatible type <c_sharp_variant_compatible_types>` is expected.
  17. Rule description
  18. ----------------
  19. Every exported member must be Variant-compatible so it can be marshalled by
  20. the engine.
  21. .. code-block:: csharp
  22. class SomeType { }
  23. // SomeType is not a valid member type because it doesn't derive from GodotObject,
  24. // so it's not compatible with Variant.
  25. [Export]
  26. public SomeType InvalidProperty { get; set; }
  27. // System.Int32 is a valid type because it's compatible with Variant.
  28. [Export]
  29. public int ValidProperty { get; set; }
  30. How to fix violations
  31. ---------------------
  32. To fix a violation of this rule, change the member's type to be Variant-compatible
  33. or remove the ``[Export]`` attribute.
  34. When to suppress warnings
  35. -------------------------
  36. Do not suppress a warning from this rule. Members with types that can't be marshalled
  37. will result in runtime errors.