-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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 #88495 from paulloz/dotnet/test-and-fix-exports-di…
…agnostics [.NET] Test and fix exports diagnostics
- Loading branch information
Showing
19 changed files
with
242 additions
and
9 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ExportDiagnosticsTests.cs
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,77 @@ | ||
using Xunit; | ||
|
||
namespace Godot.SourceGenerators.Tests; | ||
|
||
public class ExportDiagnosticsTests | ||
{ | ||
[Fact] | ||
public async void StaticMembers() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
"ExportDiagnostics_GD0101.cs", | ||
"ExportDiagnostics_GD0101_ScriptPropertyDefVal.generated.cs" | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void TypeIsNotSupported() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
"ExportDiagnostics_GD0102.cs", | ||
"ExportDiagnostics_GD0102_ScriptPropertyDefVal.generated.cs" | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void ReadOnly() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
"ExportDiagnostics_GD0103.cs", | ||
"ExportDiagnostics_GD0103_ScriptPropertyDefVal.generated.cs" | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void WriteOnly() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
"ExportDiagnostics_GD0104.cs", | ||
"ExportDiagnostics_GD0104_ScriptPropertyDefVal.generated.cs" | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void Indexer() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
"ExportDiagnostics_GD0105.cs", | ||
"ExportDiagnostics_GD0105_ScriptPropertyDefVal.generated.cs" | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void ExplicitInterfaceImplementation() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
new string[] { "ExportDiagnostics_GD0106.cs" }, | ||
new string[] | ||
{ | ||
"ExportDiagnostics_GD0106_OK_ScriptPropertyDefVal.generated.cs", | ||
"ExportDiagnostics_GD0106_KO_ScriptPropertyDefVal.generated.cs", | ||
} | ||
); | ||
} | ||
|
||
[Fact] | ||
public async void NodeExports() | ||
{ | ||
await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify( | ||
new string[] { "ExportDiagnostics_GD0107.cs" }, | ||
new string[] | ||
{ | ||
"ExportDiagnostics_GD0107_OK_ScriptPropertyDefVal.generated.cs", | ||
"ExportDiagnostics_GD0107_KO_ScriptPropertyDefVal.generated.cs", | ||
} | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ests/TestData/GeneratedSources/ExportDiagnostics_GD0101_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0101 | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...ests/TestData/GeneratedSources/ExportDiagnostics_GD0102_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0102 | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...ests/TestData/GeneratedSources/ExportDiagnostics_GD0103_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0103 | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...ests/TestData/GeneratedSources/ExportDiagnostics_GD0104_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0104 | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...ests/TestData/GeneratedSources/ExportDiagnostics_GD0105_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0105 | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...s/TestData/GeneratedSources/ExportDiagnostics_GD0106_KO_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0106_KO | ||
{ | ||
} |
21 changes: 21 additions & 0 deletions
21
...s/TestData/GeneratedSources/ExportDiagnostics_GD0106_OK_ScriptPropertyDefVal.generated.cs
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,21 @@ | ||
partial class ExportDiagnostics_GD0106_OK | ||
{ | ||
#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword | ||
#if TOOLS | ||
/// <summary> | ||
/// Get the default values for all properties declared in this class. | ||
/// This method is used by Godot to determine the value that will be | ||
/// used by the inspector when resetting properties. | ||
/// Do not call this method. | ||
/// </summary> | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
internal new static global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant> GetGodotPropertyDefaultValues() | ||
{ | ||
var values = new global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant>(1); | ||
int __MyProperty_default_value = default; | ||
values.Add(PropertyName.MyProperty, global::Godot.Variant.From<int>(__MyProperty_default_value)); | ||
return values; | ||
} | ||
#endif // TOOLS | ||
#pragma warning restore CS0109 | ||
} |
3 changes: 3 additions & 0 deletions
3
...s/TestData/GeneratedSources/ExportDiagnostics_GD0107_KO_ScriptPropertyDefVal.generated.cs
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,3 @@ | ||
partial class ExportDiagnostics_GD0107_KO | ||
{ | ||
} |
23 changes: 23 additions & 0 deletions
23
...s/TestData/GeneratedSources/ExportDiagnostics_GD0107_OK_ScriptPropertyDefVal.generated.cs
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,23 @@ | ||
partial class ExportDiagnostics_GD0107_OK | ||
{ | ||
#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword | ||
#if TOOLS | ||
/// <summary> | ||
/// Get the default values for all properties declared in this class. | ||
/// This method is used by Godot to determine the value that will be | ||
/// used by the inspector when resetting properties. | ||
/// Do not call this method. | ||
/// </summary> | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
internal new static global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant> GetGodotPropertyDefaultValues() | ||
{ | ||
var values = new global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant>(2); | ||
global::Godot.Node __NodeProperty_default_value = default; | ||
values.Add(PropertyName.NodeProperty, global::Godot.Variant.From<global::Godot.Node>(__NodeProperty_default_value)); | ||
global::Godot.Node __NodeField_default_value = default; | ||
values.Add(PropertyName.NodeField, global::Godot.Variant.From<global::Godot.Node>(__NodeField_default_value)); | ||
return values; | ||
} | ||
#endif // TOOLS | ||
#pragma warning restore CS0109 | ||
} |
10 changes: 10 additions & 0 deletions
10
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0101.cs
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,10 @@ | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0101 : Node | ||
{ | ||
[Export] | ||
public static string {|GD0101:StaticField|}; | ||
|
||
[Export] | ||
public static int {|GD0101:StaticProperty|} { get; set; } | ||
} |
12 changes: 12 additions & 0 deletions
12
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0102.cs
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,12 @@ | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0102 : Node | ||
{ | ||
public struct MyStruct { } | ||
|
||
[Export] | ||
public MyStruct {|GD0102:StructField|}; | ||
|
||
[Export] | ||
public MyStruct {|GD0102:StructProperty|} { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0103.cs
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,10 @@ | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0103 : Node | ||
{ | ||
[Export] | ||
public readonly string {|GD0103:ReadOnlyField|}; | ||
|
||
[Export] | ||
public string {|GD0103:ReadOnlyProperty|} { get; } | ||
} |
7 changes: 7 additions & 0 deletions
7
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0104.cs
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,7 @@ | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0104 : Node | ||
{ | ||
[Export] | ||
public string {|GD0104:WriteOnlyProperty|} { set { } } | ||
} |
12 changes: 12 additions & 0 deletions
12
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0105.cs
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,12 @@ | ||
using System; | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0105 : Node | ||
{ | ||
[Export] | ||
public int {|GD0105:this|}[int index] | ||
{ | ||
get { return index; } | ||
set { } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0106.cs
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,18 @@ | ||
using Godot; | ||
|
||
public interface MyInterface | ||
{ | ||
public int MyProperty { get; set; } | ||
} | ||
|
||
public partial class ExportDiagnostics_GD0106_OK : Node, MyInterface | ||
{ | ||
[Export] | ||
public int MyProperty { get; set; } | ||
} | ||
|
||
public partial class ExportDiagnostics_GD0106_KO : Node, MyInterface | ||
{ | ||
[Export] | ||
int MyInterface.{|GD0106:MyProperty|} { get; set; } | ||
} |
19 changes: 19 additions & 0 deletions
19
...r/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportDiagnostics_GD0107.cs
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,19 @@ | ||
using Godot; | ||
|
||
public partial class ExportDiagnostics_GD0107_OK : Node | ||
{ | ||
[Export] | ||
public Node NodeField; | ||
|
||
[Export] | ||
public Node NodeProperty { get; set; } | ||
} | ||
|
||
public partial class ExportDiagnostics_GD0107_KO : Resource | ||
{ | ||
[Export] | ||
public Node {|GD0107:NodeField|}; | ||
|
||
[Export] | ||
public Node {|GD0107:NodeProperty|} { get; set; } | ||
} |
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
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