From 50ea7ae27a567a594cc55d12c381dd48122315ec Mon Sep 17 00:00:00 2001 From: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:00:00 +1000 Subject: [PATCH] Fixed error IEventArgs implementation --- Hypercube.Client/Graphics/Event/MainWindowClosedEvent.cs | 3 ++- .../Entities/Realisation/EventBus/EntitiesEventBus.cs | 8 ++++---- .../Runtimes/Event/RuntimeInitializationEvent.cs | 6 ++++-- Hypercube.Shared/Runtimes/Event/RuntimeShutdownEvent.cs | 6 ++++-- Hypercube.Shared/Runtimes/Event/RuntimeStartupEvent.cs | 6 ++++-- Hypercube.Shared/Runtimes/Loop/Event/RenderFrameEvent.cs | 6 ++++-- Hypercube.Shared/Runtimes/Loop/Event/UpdateFrameEvent.cs | 6 ++++-- Hypercube.UnitTests/EventBus/EventBusRaiseTests.cs | 4 ++-- Hypercube.UnitTests/EventBus/EventBusRefStructTests.cs | 2 +- Hypercube.UnitTests/EventBus/EventBusUnsubscribeTests.cs | 4 ++-- 10 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Hypercube.Client/Graphics/Event/MainWindowClosedEvent.cs b/Hypercube.Client/Graphics/Event/MainWindowClosedEvent.cs index d24029c..1372c1e 100644 --- a/Hypercube.Client/Graphics/Event/MainWindowClosedEvent.cs +++ b/Hypercube.Client/Graphics/Event/MainWindowClosedEvent.cs @@ -1,8 +1,9 @@ using Hypercube.Client.Graphics.Windows; +using Hypercube.Shared.EventBus.Events; namespace Hypercube.Client.Graphics.Event; -public readonly struct MainWindowClosedEvent(WindowRegistration registration) +public readonly struct MainWindowClosedEvent(WindowRegistration registration) : IEventArgs { public readonly WindowRegistration Registration = registration; } \ No newline at end of file diff --git a/Hypercube.Shared/Entities/Realisation/EventBus/EntitiesEventBus.cs b/Hypercube.Shared/Entities/Realisation/EventBus/EntitiesEventBus.cs index c549397..4b21b4f 100644 --- a/Hypercube.Shared/Entities/Realisation/EventBus/EntitiesEventBus.cs +++ b/Hypercube.Shared/Entities/Realisation/EventBus/EntitiesEventBus.cs @@ -4,12 +4,12 @@ namespace Hypercube.Shared.Entities.Realisation.EventBus; public sealed class EntitiesEventBus : IEntitiesEventBus { - public void Unsubscribe(IEventSubscriber subscriber) + public void Unsubscribe(IEventSubscriber subscriber) where T : IEventArgs { throw new NotImplementedException(); } - public void Subscribe(IEventSubscriber subscriber, EventRefHandler refHandler) where T : notnull + public void Subscribe(IEventSubscriber subscriber, EventRefHandler refHandler) where T : IEventArgs { throw new NotImplementedException(); } @@ -19,12 +19,12 @@ public void Raise(object receiver) throw new NotImplementedException(); } - public void Raise(ref T receiver) where T : notnull + public void Raise(ref T receiver) where T : IEventArgs { throw new NotImplementedException(); } - public void Raise(T receiver) where T : notnull + public void Raise(T receiver) where T : IEventArgs { throw new NotImplementedException(); } diff --git a/Hypercube.Shared/Runtimes/Event/RuntimeInitializationEvent.cs b/Hypercube.Shared/Runtimes/Event/RuntimeInitializationEvent.cs index a0691f0..bffad53 100644 --- a/Hypercube.Shared/Runtimes/Event/RuntimeInitializationEvent.cs +++ b/Hypercube.Shared/Runtimes/Event/RuntimeInitializationEvent.cs @@ -1,3 +1,5 @@ -namespace Hypercube.Shared.Runtimes.Event; +using Hypercube.Shared.EventBus.Events; -public readonly record struct RuntimeInitializationEvent; \ No newline at end of file +namespace Hypercube.Shared.Runtimes.Event; + +public readonly record struct RuntimeInitializationEvent : IEventArgs; \ No newline at end of file diff --git a/Hypercube.Shared/Runtimes/Event/RuntimeShutdownEvent.cs b/Hypercube.Shared/Runtimes/Event/RuntimeShutdownEvent.cs index e3c97bf..e89ee29 100644 --- a/Hypercube.Shared/Runtimes/Event/RuntimeShutdownEvent.cs +++ b/Hypercube.Shared/Runtimes/Event/RuntimeShutdownEvent.cs @@ -1,3 +1,5 @@ -namespace Hypercube.Shared.Runtimes.Event; +using Hypercube.Shared.EventBus.Events; -public readonly record struct RuntimeShutdownEvent(string Reason); \ No newline at end of file +namespace Hypercube.Shared.Runtimes.Event; + +public readonly record struct RuntimeShutdownEvent(string Reason) : IEventArgs; \ No newline at end of file diff --git a/Hypercube.Shared/Runtimes/Event/RuntimeStartupEvent.cs b/Hypercube.Shared/Runtimes/Event/RuntimeStartupEvent.cs index 3985d95..7f3b673 100644 --- a/Hypercube.Shared/Runtimes/Event/RuntimeStartupEvent.cs +++ b/Hypercube.Shared/Runtimes/Event/RuntimeStartupEvent.cs @@ -1,3 +1,5 @@ -namespace Hypercube.Shared.Runtimes.Event; +using Hypercube.Shared.EventBus.Events; -public readonly record struct RuntimeStartupEvent; \ No newline at end of file +namespace Hypercube.Shared.Runtimes.Event; + +public readonly record struct RuntimeStartupEvent : IEventArgs; \ No newline at end of file diff --git a/Hypercube.Shared/Runtimes/Loop/Event/RenderFrameEvent.cs b/Hypercube.Shared/Runtimes/Loop/Event/RenderFrameEvent.cs index cf76f7d..05d25ed 100644 --- a/Hypercube.Shared/Runtimes/Loop/Event/RenderFrameEvent.cs +++ b/Hypercube.Shared/Runtimes/Loop/Event/RenderFrameEvent.cs @@ -1,6 +1,8 @@ -namespace Hypercube.Shared.Runtimes.Loop.Event; +using Hypercube.Shared.EventBus.Events; -public readonly struct RenderFrameEvent(float deltaSeconds) +namespace Hypercube.Shared.Runtimes.Loop.Event; + +public readonly struct RenderFrameEvent(float deltaSeconds) : IEventArgs { public readonly float DeltaSeconds = deltaSeconds; } \ No newline at end of file diff --git a/Hypercube.Shared/Runtimes/Loop/Event/UpdateFrameEvent.cs b/Hypercube.Shared/Runtimes/Loop/Event/UpdateFrameEvent.cs index 1251058..4c948c8 100644 --- a/Hypercube.Shared/Runtimes/Loop/Event/UpdateFrameEvent.cs +++ b/Hypercube.Shared/Runtimes/Loop/Event/UpdateFrameEvent.cs @@ -1,6 +1,8 @@ -namespace Hypercube.Shared.Runtimes.Loop.Event; +using Hypercube.Shared.EventBus.Events; -public readonly struct UpdateFrameEvent(float deltaSeconds) +namespace Hypercube.Shared.Runtimes.Loop.Event; + +public readonly struct UpdateFrameEvent(float deltaSeconds) : IEventArgs { public readonly float DeltaSeconds = deltaSeconds; } \ No newline at end of file diff --git a/Hypercube.UnitTests/EventBus/EventBusRaiseTests.cs b/Hypercube.UnitTests/EventBus/EventBusRaiseTests.cs index aa940ce..3af5229 100644 --- a/Hypercube.UnitTests/EventBus/EventBusRaiseTests.cs +++ b/Hypercube.UnitTests/EventBus/EventBusRaiseTests.cs @@ -50,7 +50,7 @@ public void AssertPassed() } } - private readonly record struct TestSubEventStruct; + private readonly record struct TestSubEventStruct : IEventArgs; - private sealed class TestSubEventClass; + private sealed class TestSubEventClass : IEventArgs; } \ No newline at end of file diff --git a/Hypercube.UnitTests/EventBus/EventBusRefStructTests.cs b/Hypercube.UnitTests/EventBus/EventBusRefStructTests.cs index c3ceb30..f54d7cf 100644 --- a/Hypercube.UnitTests/EventBus/EventBusRefStructTests.cs +++ b/Hypercube.UnitTests/EventBus/EventBusRefStructTests.cs @@ -50,5 +50,5 @@ private void RefMethod(ref TestEventStruct args) } } - private record struct TestEventStruct(int Counter = 0); + private record struct TestEventStruct(int Counter = 0) : IEventArgs; } \ No newline at end of file diff --git a/Hypercube.UnitTests/EventBus/EventBusUnsubscribeTests.cs b/Hypercube.UnitTests/EventBus/EventBusUnsubscribeTests.cs index 27bcbf6..6d63474 100644 --- a/Hypercube.UnitTests/EventBus/EventBusUnsubscribeTests.cs +++ b/Hypercube.UnitTests/EventBus/EventBusUnsubscribeTests.cs @@ -61,7 +61,7 @@ public void AssertPassed() } } - private record struct TestUnsubEventStruct; + private record struct TestUnsubEventStruct : IEventArgs; - private sealed class TestUnsubEventClass; + private sealed class TestUnsubEventClass : IEventArgs; } \ No newline at end of file