diff --git a/mROA.Codegen/mROA.Codegen.csproj b/mROA.Codegen/mROA.Codegen.csproj
index c7687af..55fe8a0 100644
--- a/mROA.Codegen/mROA.Codegen.csproj
+++ b/mROA.Codegen/mROA.Codegen.csproj
@@ -17,7 +17,7 @@
https://github.com/YaslePoy/mROA
git
True
- 1.0.6
+ 1.0.7
diff --git a/mROA.Codegen/SampleIncrementalSourceGenerator.cs b/mROA.Codegen/mROASourceGenerator.cs
similarity index 99%
rename from mROA.Codegen/SampleIncrementalSourceGenerator.cs
rename to mROA.Codegen/mROASourceGenerator.cs
index 57f635e..dc1a337 100644
--- a/mROA.Codegen/SampleIncrementalSourceGenerator.cs
+++ b/mROA.Codegen/mROASourceGenerator.cs
@@ -14,7 +14,7 @@ namespace mROA.Codegen;
/// When using the source code as a baseline, an incremental source generator is preferable because it reduces the performance overhead.
///
[Generator]
-public class SampleIncrementalSourceGenerator : IIncrementalGenerator
+public class mROASourceGenerator : IIncrementalGenerator
{
private const string Namespace = "mROA.Implementation";
private const string AttributeName = "SharedObjectInterafceAttribute";
diff --git a/mROA/Abstract/IFrontendBridge.cs b/mROA/Abstract/IFrontendBridge.cs
index adaa321..103fec2 100644
--- a/mROA/Abstract/IFrontendBridge.cs
+++ b/mROA/Abstract/IFrontendBridge.cs
@@ -1,5 +1,3 @@
namespace mROA.Abstract;
-public interface IFrontendBridge : IInjectableModule
-{
-}
\ No newline at end of file
+public interface IFrontendBridge : IInjectableModule;
\ No newline at end of file
diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs
index d9e19bf..cf05375 100644
--- a/mROA/Implementation/Backend/BasicExecutionModule.cs
+++ b/mROA/Implementation/Backend/BasicExecutionModule.cs
@@ -10,22 +10,32 @@ public class BasicExecutionModule : IExecuteModule
public void Inject(T dependency)
{
- if (dependency is IMethodRepository methodRepo)
- _methodRepo = methodRepo;
-
- if (dependency is IContextRepository contextRepo)
- _contextRepo = contextRepo;
+ switch (dependency)
+ {
+ case IMethodRepository methodRepo:
+ _methodRepo = methodRepo;
+ break;
+ case IContextRepository contextRepo:
+ _contextRepo = contextRepo;
+ break;
+ }
}
public ICommandExecution Execute(ICallRequest command)
{
- var currentCommand = _methodRepo!.GetMethod(command.CommandId);
+ if (_methodRepo is null)
+ throw new NullReferenceException("Method repository was not defined");
+
+ if (_contextRepo is null)
+ throw new NullReferenceException("Context repository was not defined");
+
+ var currentCommand = _methodRepo.GetMethod(command.CommandId);
if (currentCommand == null)
throw new Exception($"Command {command.CommandId} not found");
var context = command.ObjectId != -1
- ? _contextRepo!.GetObject(command.ObjectId)
- : _contextRepo!.GetSingleObject(currentCommand.DeclaringType!);
+ ? _contextRepo.GetObject(command.ObjectId)
+ : _contextRepo.GetSingleObject(currentCommand.DeclaringType!);
var parameter = command.Parameter;
if (currentCommand.ReturnType.BaseType == typeof(Task) &&
@@ -61,7 +71,7 @@ public class BasicExecutionModule : IExecuteModule
}
}
- private ICommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
+ private static ICommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
ICallRequest command)
{
var tokenSource = new CancellationTokenSource();
@@ -86,7 +96,7 @@ public class BasicExecutionModule : IExecuteModule
}
}
- private ICommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
+ private static ICommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
ICallRequest command)
{
var tokenSource = new CancellationTokenSource();
diff --git a/mROA/Implementation/Backend/ContextRepository.cs b/mROA/Implementation/Backend/ContextRepository.cs
index a11fd57..8ee451d 100644
--- a/mROA/Implementation/Backend/ContextRepository.cs
+++ b/mROA/Implementation/Backend/ContextRepository.cs
@@ -12,8 +12,8 @@ public class ContextRepository : IContextRepository
private Task _lastIndexFinder = Task.FromResult(0);
- const int StartupSize = 1024;
- const int GrowSize = 128;
+ private const int StartupSize = 1024;
+ private const int GrowSize = 128;
public void FillSingletons(params Assembly[] assembly)
@@ -70,7 +70,7 @@ public class ContextRepository : IContextRepository
private int FindLastIndex()
{
- for (int i = 0; i < _storage.Length; i++)
+ for (var i = 0; i < _storage.Length; i++)
{
if (_storage[i] is null)
return i;
diff --git a/mROA/Implementation/Backend/JsonSerialisationModule.cs b/mROA/Implementation/Backend/JsonSerialisationModule.cs
index 5effc16..3e652cb 100644
--- a/mROA/Implementation/Backend/JsonSerialisationModule.cs
+++ b/mROA/Implementation/Backend/JsonSerialisationModule.cs
@@ -28,23 +28,6 @@ public class JsonSerialisationModule : ISerialisationModule
public void PostResponse(ICommandExecution call)
{
var texted = JsonSerializer.Serialize(call, call.GetType());
- // if (call is TypedFinalCommandExecution nonVoidCall)
- // {
- // texted = JsonSerializer.Serialize(nonVoidCall);
- // }
- // else if (call is FinalCommandExecution finalCommand)
- // {
- // texted = JsonSerializer.Serialize(finalCommand);
- // }
- // else if (call is AsyncCommandExecution asyncCommand)
- // {
- // texted = JsonSerializer.Serialize(asyncCommand);
- // }
- // else if (call is ExceptionCommandExecution exceptionCommandExecution)
- // {
- // texted = JsonSerializer.Serialize(exceptionCommandExecution);
- // }
-
var binary = Encoding.UTF8.GetBytes(texted);
_dataSource!.SendTo(call.ClientId, binary);
}
diff --git a/mROA/Implementation/Backend/NetworkGatewayModule.cs b/mROA/Implementation/Backend/NetworkGatewayModule.cs
index 8817185..62b85c7 100644
--- a/mROA/Implementation/Backend/NetworkGatewayModule.cs
+++ b/mROA/Implementation/Backend/NetworkGatewayModule.cs
@@ -40,6 +40,7 @@ public class NetworkGatewayModule(IPEndPoint endpoint) : IGatewayModule
{
if (_interactionModule is null)
throw new NullReferenceException("Interaction module is null");
+
while (true)
{
var client = _tcpListener.AcceptTcpClient();
diff --git a/mROA/Implementation/Bootstrap/FullMixBuilder.cs b/mROA/Implementation/Bootstrap/FullMixBuilder.cs
index ed74e41..848480d 100644
--- a/mROA/Implementation/Bootstrap/FullMixBuilder.cs
+++ b/mROA/Implementation/Bootstrap/FullMixBuilder.cs
@@ -2,14 +2,10 @@ using mROA.Abstract;
namespace mROA.Implementation.Bootstrap;
-public interface IRoaBuilder
+public class FullMixBuilder
{
- void Build();
-}
+ public List Modules { get; } = [];
-public class FullMixBuilder : IRoaBuilder
-{
- public List Modules { get; } = new();
public void Build()
{
foreach (var module in Modules)
diff --git a/mROA/Implementation/CallRequest.cs b/mROA/Implementation/CallRequest.cs
index 0f81d37..5ca6a44 100644
--- a/mROA/Implementation/CallRequest.cs
+++ b/mROA/Implementation/CallRequest.cs
@@ -2,7 +2,7 @@
public interface ICallRequest
{
- Guid CallRequestId { get; internal set; }
+ Guid CallRequestId { get; }
int CommandId { get; }
int ObjectId { get; }
object? Parameter { get; }
diff --git a/mROA/Implementation/FinalCommandExecution.cs b/mROA/Implementation/FinalCommandExecution.cs
index 209b63b..2b960a1 100644
--- a/mROA/Implementation/FinalCommandExecution.cs
+++ b/mROA/Implementation/FinalCommandExecution.cs
@@ -11,12 +11,12 @@ public class FinalCommandExecution : ICommandExecution
[JsonIgnore]
public int ClientId { get; set; }
[JsonIgnore]
- public int CommandId { get; set; }
+ public int CommandId { get; init; }
}
public class FinalCommandExecution : FinalCommandExecution
{
- public T? Result { get; set; }
+ public T? Result { get; init; }
}
public class TypedFinalCommandExecution : FinalCommandExecution