diff --git a/tutorials/scripting/c_sharp/c_sharp_collections.rst b/tutorials/scripting/c_sharp/c_sharp_collections.rst index e5c00ea2d08..98a78f2a9c6 100644 --- a/tutorials/scripting/c_sharp/c_sharp_collections.rst +++ b/tutorials/scripting/c_sharp/c_sharp_collections.rst @@ -46,8 +46,8 @@ To choose which collection type to use for each situation, consider the followin * Does your collection need to interact with the Godot engine? (e.g.: the type of an exported property, calling a Godot method). - * If yes, since Godot only supports :ref:`Variant-compatible ` - types, use a Godot collection. + * If yes, since Godot only supports :ref:`c_sharp_variant_compatible_types`, + use a Godot collection. * If not, consider `choosing an appropriate .NET collection `_. * Do you need a Godot collection that represents a list or sequential set of data? @@ -89,8 +89,7 @@ GDScript C# ====================== ============================================================== Other C# arrays are not supported by the Godot C# API since a packed array equivalent -does not exist. See :ref:`Variant ` for a list of all the compatible -types. +does not exist. See the list of :ref:`c_sharp_variant_compatible_types`. .. _doc_c_sharp_collections_array: @@ -101,7 +100,7 @@ Godot arrays are implemented as an array of ``Variant`` and can contain several of any type. In C#, the equivalent type is ``Godot.Collections.Array``. The generic ``Godot.Collections.Array`` type allows restricting the element type to -a :ref:`Variant-compatible ` type. +a :ref:`Variant-compatible type `. An untyped ``Godot.Collections.Array`` can be converted to a typed array using the ``Godot.Collections.Array(Godot.Collections.Array)`` constructor. @@ -195,7 +194,7 @@ Godot dictionaries are implemented as a dictionary with ``Variant`` keys and val In C#, the equivalent type is ``Godot.Collections.Dictionary``. The generic ``Godot.Collections.Dictionary`` type allows restricting the key -and value types to a :ref:`Variant-compatible ` type. +and value types to a :ref:`Variant-compatible type `. An untyped ``Godot.Collections.Dictionary`` can be converted to a typed dictionary using the ``Godot.Collections.Dictionary(Godot.Collections.Dictionary)`` constructor. diff --git a/tutorials/scripting/c_sharp/c_sharp_differences.rst b/tutorials/scripting/c_sharp/c_sharp_differences.rst index 14466fed3ac..7fb100f75cc 100644 --- a/tutorials/scripting/c_sharp/c_sharp_differences.rst +++ b/tutorials/scripting/c_sharp/c_sharp_differences.rst @@ -810,7 +810,7 @@ Variant ------- ``Godot.Variant`` is used to represent Godot's native :ref:`Variant ` type. -Any Variant-compatible type can be converted from/to it. +Any :ref:`Variant-compatible type ` can be converted from/to it. See also: :ref:`doc_c_sharp_variant`. diff --git a/tutorials/scripting/c_sharp/c_sharp_exports.rst b/tutorials/scripting/c_sharp/c_sharp_exports.rst index 53aa04d6486..6402ea78522 100644 --- a/tutorials/scripting/c_sharp/c_sharp_exports.rst +++ b/tutorials/scripting/c_sharp/c_sharp_exports.rst @@ -26,7 +26,7 @@ them visible and editable in the editor. This way, artists and game designers can modify values that later influence how the program runs. For this, a special export syntax is provided. -Exporting can only be done with :ref:`Variant-compatible ` types. +Exporting can only be done with :ref:`c_sharp_variant_compatible_types`. .. note:: @@ -543,7 +543,7 @@ The default value of Godot dictionaries is null. A different default can be spec Exporting C# arrays ^^^^^^^^^^^^^^^^^^^ -C# arrays can exported as long as the element type is a :ref:`Variant-compatible ` type. +C# arrays can exported as long as the element type is a :ref:`Variant-compatible type `. .. code-block:: csharp diff --git a/tutorials/scripting/c_sharp/c_sharp_signals.rst b/tutorials/scripting/c_sharp/c_sharp_signals.rst index 50a890f7c6c..57c64fde262 100644 --- a/tutorials/scripting/c_sharp/c_sharp_signals.rst +++ b/tutorials/scripting/c_sharp/c_sharp_signals.rst @@ -91,7 +91,7 @@ your custom signal names are listed under the nested ``SignalName`` class. In contrast with other C# events, you cannot use ``Invoke`` to raise events tied to Godot signals. -Signals support arguments of any :ref:`Variant-compatible ` type. +Signals support arguments of any :ref:`Variant-compatible type `. Consequently, any ``Node`` or ``RefCounted`` will be compatible automatically, but custom data objects will need to inherit from ``GodotObject`` or one of its subclasses. diff --git a/tutorials/scripting/c_sharp/c_sharp_variant.rst b/tutorials/scripting/c_sharp/c_sharp_variant.rst index c68035a2472..832c0211055 100644 --- a/tutorials/scripting/c_sharp/c_sharp_variant.rst +++ b/tutorials/scripting/c_sharp/c_sharp_variant.rst @@ -5,7 +5,8 @@ C# Variant For a detailed explanation of Variant in general, see the :ref:`Variant ` documentation page. -``Godot.Variant`` is used to represent Godot's native :ref:`Variant ` type. Any Variant-compatible type can be converted from/to it. +``Godot.Variant`` is used to represent Godot's native :ref:`Variant ` type. Any +:ref:`Variant-compatible type ` can be converted from/to it. We recommend avoiding ``Godot.Variant`` unless it is necessary to interact with untyped engine APIs. Take advantage of C#'s type safety when possible. @@ -21,9 +22,14 @@ to a ``Godot.Variant``. Since the Variant type in C# is a struct, it can't be null. To create a "null" Variant use the ``default`` keyword or the parameterless constructor. +.. _c_sharp_variant_compatible_types: + Variant-compatible types ------------------------ +A Variant-compatible type can be converted to and from a ``Godot.Variant``. +These C# types are Variant-compatible: + * All the `built-in value types `_, except ``decimal``, ``nint`` and ``nuint``. * ``string``. diff --git a/tutorials/scripting/c_sharp/diagnostics/GD0102.rst b/tutorials/scripting/c_sharp/diagnostics/GD0102.rst index 159e6af6d3b..3f76f8bb81d 100644 --- a/tutorials/scripting/c_sharp/diagnostics/GD0102.rst +++ b/tutorials/scripting/c_sharp/diagnostics/GD0102.rst @@ -16,7 +16,8 @@ Cause ----- An unsupported type is specified for a member annotated with the ``[Export]`` -attribute when a :ref:`Variant-compatible ` type is expected. +attribute when a +:ref:`Variant-compatible type ` is expected. Rule description ---------------- diff --git a/tutorials/scripting/c_sharp/diagnostics/GD0202.rst b/tutorials/scripting/c_sharp/diagnostics/GD0202.rst index 54c5dd79fca..17dc4f3ffee 100644 --- a/tutorials/scripting/c_sharp/diagnostics/GD0202.rst +++ b/tutorials/scripting/c_sharp/diagnostics/GD0202.rst @@ -16,8 +16,8 @@ Cause ----- An unsupported type is specified for a parameter of a delegate annotated with -the ``[Signal]`` attribute when a :ref:`Variant-compatible ` -type is expected. +the ``[Signal]`` attribute when a +:ref:`Variant-compatible type ` is expected. Rule description ---------------- diff --git a/tutorials/scripting/c_sharp/diagnostics/GD0301.rst b/tutorials/scripting/c_sharp/diagnostics/GD0301.rst index 6a4e73c4d1e..ca6151ced2b 100644 --- a/tutorials/scripting/c_sharp/diagnostics/GD0301.rst +++ b/tutorials/scripting/c_sharp/diagnostics/GD0301.rst @@ -14,7 +14,7 @@ Cause ----- An unsupported type is specified for a generic type argument when a -:ref:`Variant-compatible ` type is expected. +:ref:`Variant-compatible type ` is expected. Rule description ---------------- diff --git a/tutorials/scripting/c_sharp/diagnostics/GD0302.rst b/tutorials/scripting/c_sharp/diagnostics/GD0302.rst index 39cfd914ea1..bc75e3cd2f2 100644 --- a/tutorials/scripting/c_sharp/diagnostics/GD0302.rst +++ b/tutorials/scripting/c_sharp/diagnostics/GD0302.rst @@ -14,8 +14,9 @@ Cause ----- A generic type is specified for a generic type argument when a -:ref:`Variant-compatible ` type is expected, but the -specified generic type is not annotated with the ``[MustBeVariant]`` attribute. +:ref:`Variant-compatible type ` is expected, +but the specified generic type is not annotated with the ``[MustBeVariant]`` +attribute. Rule description ----------------