Skip to content

Commit 8f2ea4f

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 8f2ea4f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tutorials/scripting/c_sharp/c_sharp_exports.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,14 @@ 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+
..
577+
See Godot.SourceGenerators.MarshalUtils.ConvertManagedTypeToMarshalType for the function which determines what can be marshalled
578+
579+
C# arrays can exported as long as it not multi-dimensional, and the element type is one of the following:
580+
581+
* A native C# ``byte``, ``int``/``Int32``, ``Int64``, ``float``, ``double``, or ``string``.
582+
* Anything derived from ``GodotObject``.
583+
* Godot's ``Vector2``, ``Vector3``, ``Vector4``, ``Color``, ``StringName``, ``NodePath``, or ``Rid``.
577584

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

588598
.. code-block:: csharp

tutorials/scripting/c_sharp/diagnostics/GD0102.rst

+2
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)