Skip to content

Commit 6324f68

Browse files
committed
Fix documentation on exportable C# native arrays
It's quite hard to tell what is and isn't permissible from the current description, and there are both false positives and negatives. This makes explicit what is and isn't permissible, and suggests a general workaround when the relevant diagnostic is raised for a native array type.
1 parent 1a72210 commit 6324f68

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tutorials/scripting/c_sharp/c_sharp_exports.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,13 @@ The default value of Godot dictionaries is null. A different default can be spec
573573
Exporting C# arrays
574574
^^^^^^^^^^^^^^^^^^^
575575

576-
C# arrays can exported as long as the element type is a :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
576+
C# arrays can exported as long as it not multi-dimensional, and the element type is one of the following:
577+
578+
..
579+
See Godot.SourceGenerators.MarshalUtils.ConvertManagedTypeToMarshalType for the function which determines what can be marshalled
580+
* A native C# ``byte``, ``int``/``Int32``, ``Int64``, ``float``, ``double``, or ``string``.
581+
* Anything derived from ``GodotObject``.
582+
* Godot's ``Vector2``, ``Vector3``, ``Vector4``, ``Color``, ``StringName``, ``NodePath``, or ``Rid``.
577583

578584
.. code-block:: csharp
579585
@@ -583,6 +589,9 @@ C# arrays can exported as long as the element type is a :ref:`Variant-compatible
583589
[Export]
584590
public NodePath[] NodePaths { get; set; }
585591
592+
Other element types, even other :ref:`Variant-compatible types <c_sharp_variant_compatible_types>` such as ``Plane`` or ``Transform2D``, will not work.
593+
If you get a :ref:`GD0102 <doc_c_sharp_diagnostics_gd0102>` error, use a ``Godot.Collections.Array`` instead.
594+
586595
The default value of C# arrays is null. A different default can be specified:
587596

588597
.. code-block:: csharp

tutorials/scripting/c_sharp/diagnostics/GD0102.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _doc_c_sharp_diagnostics_gd0102:
2+
13
GD0102: The type of the exported member is not supported
24
========================================================
35

0 commit comments

Comments
 (0)