Skip to content

Commit c758c6c

Browse files
committed
[#1] FIXED Adding instanced scene namespace as custom type
1 parent 24163b9 commit c758c6c

15 files changed

Lines changed: 104 additions & 12 deletions

CustomGeneratorTests/CustomGeneratorTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="GodotSharp.SourceGenerators" Version="1.1.0" />
12+
<PackageReference Include="GodotSharp.SourceGenerators" Version="1.1.1" />
1313
</ItemGroup>
1414
</Project>

GodotTests/GodotTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<ItemGroup>
1515
<PackageReference Include="FluentAssertions" Version="6.0.0-alpha0002" />
1616
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
17-
<PackageReference Include="GodotSharp.SourceGenerators" Version="1.1.0" />
17+
<PackageReference Include="GodotSharp.SourceGenerators" Version="1.1.1" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<ProjectReference Include="..\CustomGeneratorTests\CustomGeneratorTests.csproj" OutputItemType="analyzer" />

GodotTests/TestRunner/TestRunner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static IEnumerable<Func<ITest>> Tests
2626
yield return () => GetTest<EmptySceneWithNoNamespace>();
2727
yield return () => GetTest<InheritedScene>();
2828
yield return () => GetTest<InstancedScene>();
29+
yield return () => GetTest<InstancedSceneFromDifferentNamespace>();
2930
yield return () => GetTest<ScriptForSceneWithDifferentName>();
3031
yield return () => GetTest<ScriptForSceneWithDifferentPath>();
3132
}

GodotTests/TestScenes/EmptyScene.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[ext_resource path="res://TestScenes/EmptyScene.cs" type="Script" id=1]
44

5-
[node name="Control" type="Control"]
5+
[node name="Scene" type="Control"]
66
anchor_right = 1.0
77
anchor_bottom = 1.0
88
script = ExtResource( 1 )

GodotTests/TestScenes/EmptySceneWithNoNamespace.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[ext_resource path="res://TestScenes/EmptySceneWithNoNamespace.cs" type="Script" id=1]
44

5-
[node name="Control" type="Control"]
5+
[node name="Scene" type="Control"]
66
anchor_right = 1.0
77
anchor_bottom = 1.0
88
script = ExtResource( 1 )

GodotTests/TestScenes/InheritedScene.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using FluentAssertions;
23
using Godot;
34
using GodotTests.Utilities;
@@ -13,6 +14,11 @@ void ITest.InitTests()
1314
_.Local_Layout.Label2.Text.Should().Be("Label2.Local");
1415

1516
_.Local_Layout.Get().Should().Be(GetNode("Local-Layout"));
17+
18+
// Inheritance should not expose private `_` of parent
19+
_.GetType().GetProperties().Select(x => x.Name)
20+
.Should().HaveCount(1)
21+
.And.BeEquivalentTo(new[] { "Local_Layout" });
1622
}
1723
}
1824
}

GodotTests/TestScenes/InstancedScene.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace GodotTests.TestScenes
88
public abstract partial class InstancedScene : Control, ITest
99
{
1010
void ITest.InitTests()
11-
=> _.Root.Should().BeOfType<RootScene>().And.NotBeNull();
11+
=> _.InstancedScene.Should().BeOfType<RootScene>().And.NotBeNull();
1212
}
1313
}

GodotTests/TestScenes/InstancedScene.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
[ext_resource path="res://RootScene.tscn" type="PackedScene" id=1]
44
[ext_resource path="res://TestScenes/InstancedScene.cs" type="Script" id=2]
55

6-
[node name="InstancedScene" type="CenterContainer"]
6+
[node name="Scene" type="CenterContainer"]
77
anchor_right = 1.0
88
anchor_bottom = 1.0
99
script = ExtResource( 2 )
1010
__meta__ = {
1111
"_edit_use_anchors_": false
1212
}
1313

14-
[node name="Root" parent="." instance=ExtResource( 1 )]
14+
[node name="InstancedScene" parent="." instance=ExtResource( 1 )]
1515
anchor_right = 0.0
1616
anchor_bottom = 0.0
1717
offset_left = 340.0
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using FluentAssertions;
2+
using Godot;
3+
using GodotTests.TestScenes.Script;
4+
using GodotTests.Utilities;
5+
6+
namespace GodotTests.TestScenes
7+
{
8+
[SceneTree]
9+
public abstract partial class InstancedSceneFromDifferentNamespace : Control, ITest
10+
{
11+
// Known Issue: tscn and script must have same name
12+
void ITest.InitTests()
13+
=> _.InstancedScene.Should().BeOfType<SceneInDifferentNamespace>().And.NotBeNull();
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://TestScenes/Scene/SceneInDifferentNamespace.tscn" type="PackedScene" id=1]
4+
[ext_resource path="res://TestScenes/InstancedSceneFromDifferentNamespace.cs" type="Script" id=2]
5+
6+
[node name="Scene" type="CenterContainer"]
7+
anchor_right = 1.0
8+
anchor_bottom = 1.0
9+
script = ExtResource( 2 )
10+
__meta__ = {
11+
"_edit_use_anchors_": false
12+
}
13+
14+
[node name="InstancedScene" parent="." instance=ExtResource( 1 )]
15+
anchor_right = 0.0
16+
anchor_bottom = 0.0
17+
offset_left = 491.0
18+
offset_top = 281.0
19+
offset_right = 533.0
20+
offset_bottom = 319.0

0 commit comments

Comments
 (0)