This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: super objects * fix: rename WM notifications * chore: bump version
- Loading branch information
Showing
27 changed files
with
991 additions
and
214 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
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,65 @@ | ||
|
||
using Godot; | ||
using SuperNodes.Types; | ||
|
||
namespace AllNotifications; | ||
|
||
[SuperNode] | ||
public partial class Example : Node { | ||
private void OnPostinitialize() { } | ||
private void OnPredelete() { } | ||
private void OnNotification(int what) { } | ||
private void OnEnterTree() { } | ||
// not working | ||
private void OnWMWindowFocusIn() { } | ||
// not working | ||
private void OnWMWindowFocusOut() { } | ||
// not working | ||
private void OnWMCloseRequest() { } | ||
// not working | ||
private void OnWMSizeChanged() { } | ||
// not working | ||
private void OnWMDpiChange() { } | ||
private void OnVpMouseEnter() { } | ||
private void OnVpMouseExit() { } | ||
private void OnOsMemoryWarning() { } | ||
private void OnTranslationChanged() { } | ||
// not working | ||
private void OnWMAbout() { } | ||
private void OnCrash() { } | ||
private void OnOsImeUpdate() { } | ||
private void OnApplicationResumed() { } | ||
private void OnApplicationPaused() { } | ||
private void OnApplicationFocusIn() { } | ||
private void OnApplicationFocusOut() { } | ||
private void OnTextServerChanged() { } | ||
// not working | ||
private void OnWMMouseExit() { } | ||
// not working | ||
private void OnWMMouseEnter() { } | ||
// not working | ||
private void OnWMGoBackRequest() { } | ||
private void OnEditorPreSave() { } | ||
private void OnExitTree() { } | ||
private void OnMovedInParent() { } | ||
private void OnReady() { } | ||
private void OnEditorPostSave() { } | ||
private void OnUnpaused() { } | ||
private void OnPhysicsProcess(double delta) { } | ||
private void OnProcess(double delta) { } | ||
private void OnParented() { } | ||
private void OnUnparented() { } | ||
private void OnPaused() { } | ||
private void OnDragBegin() { } | ||
private void OnDragEnd() { } | ||
private void OnPathRenamed() { } | ||
private void OnInternalProcess() { } | ||
private void OnInternalPhysicsProcess() { } | ||
private void OnPostEnterTree() { } | ||
private void OnDisabled() { } | ||
private void OnEnabled() { } | ||
private void OnSceneInstantiated() { } | ||
|
||
|
||
public override partial void _Notification(int what); | ||
} |
48 changes: 48 additions & 0 deletions
48
SuperNodes.TestCases/test/test_cases/PlainOldSuperObjectTest.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,48 @@ | ||
namespace PlainOldSuperObjectTest; | ||
|
||
using System; | ||
using Chickensoft.GoDotTest; | ||
using Godot; | ||
using Shouldly; | ||
using SuperNodes.Types; | ||
|
||
public record CommonBaseType { } | ||
public interface IGreeter { } | ||
|
||
[SuperObject(typeof(Greeter))] | ||
public partial record MyPlainOldRecordType : CommonBaseType { } | ||
|
||
public partial class GrandparentType<T> { | ||
public partial class ParentType { | ||
[SuperObject(typeof(Greeter))] | ||
public partial record MyNestedPlainOldRecordType : CommonBaseType { } | ||
} | ||
} | ||
|
||
[PowerUp] | ||
public record Greeter : CommonBaseType, IGreeter { | ||
public void Greet() => Console.WriteLine("Hello, world!"); | ||
} | ||
|
||
public class PlainOldSuperObjectTest : TestClass { | ||
public PlainOldSuperObjectTest(Node testScene) : base(testScene) { } | ||
|
||
[Test] | ||
public void PlainOldObjectsWorkAsSuperObjects() { | ||
var obj = new MyPlainOldRecordType(); | ||
|
||
obj.ShouldBeOfType<MyPlainOldRecordType>(); | ||
obj.ShouldBeAssignableTo<IGreeter>(); | ||
} | ||
|
||
[Test] | ||
public void NestedPlainOldObjectsWorkAsSuperObjects() { | ||
var obj = | ||
new GrandparentType<string>.ParentType.MyNestedPlainOldRecordType(); | ||
|
||
obj.ShouldBeOfType< | ||
GrandparentType<string>.ParentType.MyNestedPlainOldRecordType | ||
>(); | ||
obj.ShouldBeAssignableTo<IGreeter>(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
71 changes: 71 additions & 0 deletions
71
SuperNodes.Tests/tests/common/models/ContainingTypeTest.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,71 @@ | ||
namespace SuperNodes.Tests.Common.Models; | ||
|
||
using System; | ||
using Shouldly; | ||
using SuperNodes.Common.Models; | ||
using Xunit; | ||
|
||
public class ContainingTypeTest { | ||
[Fact] | ||
public void Initializes() { | ||
var containingType = new ContainingType( | ||
FullName: "TestClass", | ||
Kind: ContainingTypeKind.Record, | ||
Accessibility: Microsoft.CodeAnalysis.Accessibility.Public, | ||
IsPartial: false | ||
); | ||
|
||
containingType.TypeDeclarationKeyword.ShouldBe("record"); | ||
containingType.AccessibilityKeywords.ShouldBe("public"); | ||
} | ||
|
||
[Fact] | ||
public void GetTypeDeclarationKeyword() { | ||
ContainingType.GetTypeDeclarationKeyword( | ||
ContainingTypeKind.Record | ||
).ShouldBe("record"); | ||
|
||
ContainingType.GetTypeDeclarationKeyword( | ||
ContainingTypeKind.Class | ||
).ShouldBe("class"); | ||
|
||
Should.Throw<ArgumentException>( | ||
() => ContainingType.GetTypeDeclarationKeyword( | ||
(ContainingTypeKind)3 | ||
) | ||
); | ||
} | ||
|
||
[Fact] | ||
public void GetAccessibilityKeywords() { | ||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.Public | ||
).ShouldBe("public"); | ||
|
||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.Protected | ||
).ShouldBe("protected"); | ||
|
||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.Internal | ||
).ShouldBe("internal"); | ||
|
||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.ProtectedOrInternal | ||
).ShouldBe("protected internal"); | ||
|
||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.Private | ||
).ShouldBe("private"); | ||
|
||
ContainingType.GetAccessibilityKeywords( | ||
Microsoft.CodeAnalysis.Accessibility.ProtectedAndInternal | ||
).ShouldBe("private protected"); | ||
|
||
Should.Throw<ArgumentException>( | ||
() => ContainingType.GetAccessibilityKeywords( | ||
(Microsoft.CodeAnalysis.Accessibility)7 | ||
) | ||
); | ||
} | ||
} |
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
Oops, something went wrong.