Skip to content

Commit 8b94fc9

Browse files
committed
Link to C# Variant-compatible section directly
1 parent c42e54b commit 8b94fc9

File tree

9 files changed

+24
-17
lines changed

9 files changed

+24
-17
lines changed

tutorials/scripting/c_sharp/c_sharp_collections.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ To choose which collection type to use for each situation, consider the followin
4646
* Does your collection need to interact with the Godot engine?
4747
(e.g.: the type of an exported property, calling a Godot method).
4848

49-
* If yes, since Godot only supports :ref:`Variant-compatible <doc_c_sharp_variant>`
50-
types, use a Godot collection.
49+
* If yes, since Godot only supports :ref:`c_sharp_variant_compatible_types`,
50+
use a Godot collection.
5151
* If not, consider `choosing an appropriate .NET collection <https://learn.microsoft.com/en-us/dotnet/standard/collections/selecting-a-collection-class>`_.
5252

5353
* Do you need a Godot collection that represents a list or sequential set of data?
@@ -89,8 +89,7 @@ GDScript C#
8989
====================== ==============================================================
9090

9191
Other C# arrays are not supported by the Godot C# API since a packed array equivalent
92-
does not exist. See :ref:`Variant <doc_c_sharp_variant>` for a list of all the compatible
93-
types.
92+
does not exist. See the list of :ref:`c_sharp_variant_compatible_types`.
9493

9594
.. _doc_c_sharp_collections_array:
9695

@@ -101,7 +100,7 @@ Godot arrays are implemented as an array of ``Variant`` and can contain several
101100
of any type. In C#, the equivalent type is ``Godot.Collections.Array``.
102101

103102
The generic ``Godot.Collections.Array<T>`` type allows restricting the element type to
104-
a :ref:`Variant-compatible <doc_c_sharp_variant>` type.
103+
a :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
105104

106105
An untyped ``Godot.Collections.Array`` can be converted to a typed array using the
107106
``Godot.Collections.Array<T>(Godot.Collections.Array)`` constructor.
@@ -195,7 +194,7 @@ Godot dictionaries are implemented as a dictionary with ``Variant`` keys and val
195194
In C#, the equivalent type is ``Godot.Collections.Dictionary``.
196195

197196
The generic ``Godot.Collections.Dictionary<TKey, TValue>`` type allows restricting the key
198-
and value types to a :ref:`Variant-compatible <doc_c_sharp_variant>` type.
197+
and value types to a :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
199198

200199
An untyped ``Godot.Collections.Dictionary`` can be converted to a typed dictionary using the
201200
``Godot.Collections.Dictionary<TKey, TValue>(Godot.Collections.Dictionary)`` constructor.

tutorials/scripting/c_sharp/c_sharp_differences.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ Variant
810810
-------
811811

812812
``Godot.Variant`` is used to represent Godot's native :ref:`Variant <class_Variant>` type.
813-
Any Variant-compatible type can be converted from/to it.
813+
Any :ref:`Variant-compatible type <c_sharp_variant_compatible_types>` can be converted from/to it.
814814

815815
See also: :ref:`doc_c_sharp_variant`.
816816

tutorials/scripting/c_sharp/c_sharp_exports.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ them visible and editable in the editor. This way, artists and game designers
2626
can modify values that later influence how the program runs. For this, a
2727
special export syntax is provided.
2828

29-
Exporting can only be done with :ref:`Variant-compatible <doc_c_sharp_variant>` types.
29+
Exporting can only be done with :ref:`c_sharp_variant_compatible_types`.
3030

3131
.. note::
3232

@@ -543,7 +543,7 @@ The default value of Godot dictionaries is null. A different default can be spec
543543
Exporting C# arrays
544544
^^^^^^^^^^^^^^^^^^^
545545

546-
C# arrays can exported as long as the element type is a :ref:`Variant-compatible <doc_c_sharp_variant>` type.
546+
C# arrays can exported as long as the element type is a :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
547547

548548
.. code-block:: csharp
549549

tutorials/scripting/c_sharp/c_sharp_signals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ your custom signal names are listed under the nested ``SignalName`` class.
9191
9292
In contrast with other C# events, you cannot use ``Invoke`` to raise events tied to Godot signals.
9393

94-
Signals support arguments of any :ref:`Variant-compatible <doc_c_sharp_variant>` type.
94+
Signals support arguments of any :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
9595

9696
Consequently, any ``Node`` or ``RefCounted`` will be compatible automatically, but custom data objects will need
9797
to inherit from ``GodotObject`` or one of its subclasses.

tutorials/scripting/c_sharp/c_sharp_variant.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ C# Variant
55

66
For a detailed explanation of Variant in general, see the :ref:`Variant <class_Variant>` documentation page.
77

8-
``Godot.Variant`` is used to represent Godot's native :ref:`Variant <class_Variant>` type. Any Variant-compatible type can be converted from/to it.
8+
``Godot.Variant`` is used to represent Godot's native :ref:`Variant <class_Variant>` type. Any
9+
:ref:`Variant-compatible type <c_sharp_variant_compatible_types>` can be converted from/to it.
910
We recommend avoiding ``Godot.Variant`` unless it is necessary to interact with untyped engine APIs.
1011
Take advantage of C#'s type safety when possible.
1112

@@ -21,9 +22,14 @@ to a ``Godot.Variant``.
2122
Since the Variant type in C# is a struct, it can't be null. To create a "null"
2223
Variant use the ``default`` keyword or the parameterless constructor.
2324

25+
.. _c_sharp_variant_compatible_types:
26+
2427
Variant-compatible types
2528
------------------------
2629

30+
A Variant-compatible type can be converted to and from a ``Godot.Variant``.
31+
These C# types are Variant-compatible:
32+
2733
* All the `built-in value types <https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/built-in-types-table>`_,
2834
except ``decimal``, ``nint`` and ``nuint``.
2935
* ``string``.

tutorials/scripting/c_sharp/diagnostics/GD0102.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Cause
1616
-----
1717

1818
An unsupported type is specified for a member annotated with the ``[Export]``
19-
attribute when a :ref:`Variant-compatible <doc_c_sharp_variant>` type is expected.
19+
attribute when a
20+
:ref:`Variant-compatible type <c_sharp_variant_compatible_types>` is expected.
2021

2122
Rule description
2223
----------------

tutorials/scripting/c_sharp/diagnostics/GD0202.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Cause
1616
-----
1717

1818
An unsupported type is specified for a parameter of a delegate annotated with
19-
the ``[Signal]`` attribute when a :ref:`Variant-compatible <doc_c_sharp_variant>`
20-
type is expected.
19+
the ``[Signal]`` attribute when a
20+
:ref:`Variant-compatible type <c_sharp_variant_compatible_types>` is expected.
2121

2222
Rule description
2323
----------------

tutorials/scripting/c_sharp/diagnostics/GD0301.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Cause
1414
-----
1515

1616
An unsupported type is specified for a generic type argument when a
17-
:ref:`Variant-compatible <doc_c_sharp_variant>` type is expected.
17+
:ref:`Variant-compatible type <c_sharp_variant_compatible_types>` is expected.
1818

1919
Rule description
2020
----------------

tutorials/scripting/c_sharp/diagnostics/GD0302.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ Cause
1414
-----
1515

1616
A generic type is specified for a generic type argument when a
17-
:ref:`Variant-compatible <doc_c_sharp_variant>` type is expected, but the
18-
specified generic type is not annotated with the ``[MustBeVariant]`` attribute.
17+
:ref:`Variant-compatible type <c_sharp_variant_compatible_types>` is expected,
18+
but the specified generic type is not annotated with the ``[MustBeVariant]``
19+
attribute.
1920

2021
Rule description
2122
----------------

0 commit comments

Comments
 (0)