forked from godotengine/godot-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request godotengine#7781 from raulsntos/dotnet/diagnostics
- Loading branch information
Showing
18 changed files
with
839 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
GD0001: Missing partial modifier on declaration of type which is a subclass of GodotObject | ||
========================================================================================== | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0001 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Non-breaking | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
A type that derives from ``GodotObject`` is not declared partial. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot source generators add generated code to user-defined types to implement | ||
the integration with the engine. Source generators can't add generated code to | ||
types that aren't declared partial. | ||
|
||
.. code-block:: csharp | ||
// The source generators can't enhance this type to work with Godot. | ||
public class InvalidNode : Node { } | ||
// The source generators can enhance this type to work with Godot. | ||
public partial class ValidNode { } | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, add the ``partial`` keyword to the type | ||
declaration. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Types that derive from ``GodotObject`` | ||
but aren't partial can't be enhanced by the source generators, resulting in | ||
unexpected runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
GD0002: Missing partial modifier on declaration of type which contains one or more subclasses of GodotObject | ||
============================================================================================================ | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0002 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Non-breaking | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
A type that derives from ``GodotObject`` is contained in a non-partial type declaration. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot source generators add generated code to user-defined types to implement | ||
the integration with the engine. Source generators can't add generated code to | ||
types that aren't declared partial. | ||
|
||
.. code-block:: csharp | ||
public class InvalidParentType | ||
{ | ||
// MyNode is contained in a non-partial type so the source generators | ||
// can't enhance this type to work with Godot. | ||
public partial class MyNode : Node { } | ||
} | ||
public partial class ValidParentType | ||
{ | ||
// MyNode is contained in a partial type so the source generators | ||
// can enhance this type to work with Godot. | ||
public partial class MyNode : Node { } | ||
} | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, add the ``partial`` keyword to the type | ||
declaration. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Types that derive from ``GodotObject`` | ||
but aren't partial can't be enhanced by the source generators, resulting in | ||
unexpected runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
GD0101: Attempted to export static member | ||
========================================= | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0101 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Breaking - If the ``static`` keyword is removed | ||
|
||
Non-breaking - If the ``[Export]`` attribute is removed | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
A static member is annotated with the ``[Export]`` attribute. Static members | ||
can't be exported. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot doesn't allow exporting static members. | ||
|
||
.. code-block:: csharp | ||
// Static members can't be exported. | ||
[Export] | ||
public static int InvalidProperty { get; set; } | ||
// Instance members can be exported. | ||
[Export] | ||
public int ValidProperty { get; set; } | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, remove the ``[Export]`` attribute or remove the | ||
``static`` keyword. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Static members can't be exported so | ||
they will be ignored by Godot, resulting in runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
GD0102: The type of the exported member is not supported | ||
======================================================== | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0102 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Breaking - If the member type is changed | ||
|
||
Non-breaking - If the ``[Export]`` attribute is removed | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
An unsupported type is specified for a member annotated with the ``[Export]`` | ||
attribute when a :ref:`Variant-compatible <doc_c_sharp_variant>` type is expected. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Every exported member must be Variant-compatible so it can be marshalled by | ||
the engine. | ||
|
||
.. code-block:: csharp | ||
class SomeType { } | ||
// SomeType is not a valid member type because it doesn't derive from GodotObject, | ||
// so it's not compatible with Variant. | ||
[Export] | ||
public SomeType InvalidProperty { get; set; } | ||
// System.Int32 is a valid type because it's compatible with Variant. | ||
[Export] | ||
public int ValidProperty { get; set; } | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, change the member's type to be Variant-compatible | ||
or remove the ``[Export]`` attribute. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Members with types that can't be marshalled | ||
will result in runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
GD0103: The exported member is read-only | ||
======================================== | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0103 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Non-breaking | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
A read-only member is annotated with the ``[Export]`` attribute. Read-only members | ||
can't be exported. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot doesn't allow exporting read-only members. | ||
|
||
.. code-block:: csharp | ||
// Read-only fields can't be exported. | ||
[Export] | ||
public readonly int invalidField; | ||
// This field can be exported because it's not declared 'readonly'. | ||
[Export] | ||
public int validField; | ||
// Read-only properties can't be exported. | ||
[Export] | ||
public int InvalidProperty { get; } | ||
// This property can be exported because it has both a getter and a setter. | ||
[Export] | ||
public int ValidProperty { get; set; } | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule for fields, remove the ``readonly`` keyword or | ||
remove the ``[Export]`` attribute. | ||
|
||
To fix a violation of this rule for properties, make sure the property declares | ||
both a getter and a setter, or remove the ``[Export]`` attribute. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Read-only members can't be exported so | ||
they will be ignored by Godot, resulting in runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
GD0104: The exported property is write-only | ||
=========================================== | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0104 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Non-breaking | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
A write-only property is annotated with the ``[Export]`` attribute. Write-only properties | ||
can't be exported. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot doesn't allow exporting write-only properties. | ||
|
||
.. code-block:: csharp | ||
private int _backingField; | ||
// Write-only properties can't be exported. | ||
[Export] | ||
public int InvalidProperty { set => _backingField = value; } | ||
// This property can be exported because it has both a getter and a setter. | ||
[Export] | ||
public int ValidProperty { get; set; } | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, make sure the property declares | ||
both a getter and a setter, or remove the ``[Export]`` attribute. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Write-only members can't be exported so | ||
they will be ignored by Godot, resulting in runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
GD0105: Attempted to export indexer property | ||
============================================ | ||
|
||
==================================== ====================================== | ||
Value | ||
==================================== ====================================== | ||
**Rule ID** GD0105 | ||
**Category** Usage | ||
**Fix is breaking or non-breaking** Non-breaking | ||
**Enabled by default** Yes | ||
==================================== ====================================== | ||
|
||
Cause | ||
----- | ||
|
||
An indexer is annotated with the ``[Export]`` attribute. Indexers can't be exported. | ||
|
||
Rule description | ||
---------------- | ||
|
||
Godot doesn't allow exporting indexer properties. | ||
|
||
.. code-block:: csharp | ||
private int[] _backingField; | ||
// Indexers can't be exported. | ||
[Export] | ||
public int this[int index] | ||
{ | ||
get => _backingField[index]; | ||
set => _backingField[index] = value; | ||
} | ||
How to fix violations | ||
--------------------- | ||
|
||
To fix a violation of this rule, remove the ``[Export]`` attribute. | ||
|
||
When to suppress warnings | ||
------------------------- | ||
|
||
Do not suppress a warning from this rule. Indexers can't be exported so | ||
they will be ignored by Godot, resulting in runtime errors. |
Oops, something went wrong.