diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 20758fb..07d7ff4 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -1,6 +1,5 @@ using System; using System.Net; -using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/mROA.Codegen/RemoteTypeBinder.cstmpl b/mROA.Codegen/RemoteTypeBinder.cstmpl index bbef815..69eff9c 100644 --- a/mROA.Codegen/RemoteTypeBinder.cstmpl +++ b/mROA.Codegen/RemoteTypeBinder.cstmpl @@ -11,11 +11,11 @@ namespace mROA.Codegen public sealed class RemoteTypeBinder { static RemoteTypeBinder(){ - RemoteContextRepository.RemoteTypes = new Dictionary { + RemoteInstanceRepository.RemoteTypes = new Dictionary { , }; - ContextRepository.EventBinders = new object[] { + InstanceRepository.EventBinders = new object[] { new EventBinder<> diff --git a/mROA/Abstract/IChannelInteractionModule.cs b/mROA/Abstract/IChannelInteractionModule.cs index e9030d1..2c59de3 100644 --- a/mROA/Abstract/IChannelInteractionModule.cs +++ b/mROA/Abstract/IChannelInteractionModule.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Threading.Channels; using System.Threading.Tasks; using mROA.Implementation; diff --git a/mROA/Abstract/IInstanceRepository.cs b/mROA/Abstract/IInstanceRepository.cs index 2e3ef2f..7086178 100644 --- a/mROA/Abstract/IInstanceRepository.cs +++ b/mROA/Abstract/IInstanceRepository.cs @@ -5,7 +5,6 @@ namespace mROA.Abstract { public interface IInstanceRepository : IInjectableModule { - int HostId { get; set; } int ResisterObject(object o, IEndPointContext context); void ClearObject(ComplexObjectIdentifier id, IEndPointContext context); T GetObject(ComplexObjectIdentifier id, IEndPointContext context); diff --git a/mROA/Abstract/ISerializationToolkit.cs b/mROA/Abstract/ISerializationToolkit.cs index 92b806a..6761e10 100644 --- a/mROA/Abstract/ISerializationToolkit.cs +++ b/mROA/Abstract/ISerializationToolkit.cs @@ -1,6 +1,4 @@ -using System; - -namespace mROA.Abstract +namespace mROA.Abstract { // public interface IContextualSerializationToolKit : IInjectableModule // { diff --git a/mROA/Abstract/IUntrustedGateway.cs b/mROA/Abstract/IUntrustedGateway.cs index 9cb5fee..1c6f25c 100644 --- a/mROA/Abstract/IUntrustedGateway.cs +++ b/mROA/Abstract/IUntrustedGateway.cs @@ -1,5 +1,4 @@ using System; -using System.Net; using System.Threading.Tasks; namespace mROA.Abstract diff --git a/mROA/Implementation/Backend/InstanceRepository.cs b/mROA/Implementation/Backend/InstanceRepository.cs index 9b71859..4c7c9e5 100644 --- a/mROA/Implementation/Backend/InstanceRepository.cs +++ b/mROA/Implementation/Backend/InstanceRepository.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Threading.Tasks; using mROA.Abstract; using mROA.Implementation.Attributes; diff --git a/mROA/Implementation/Backend/NetworkGatewayModule.cs b/mROA/Implementation/Backend/NetworkGatewayModule.cs index 5fc2548..f4e9d3c 100644 --- a/mROA/Implementation/Backend/NetworkGatewayModule.cs +++ b/mROA/Implementation/Backend/NetworkGatewayModule.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Threading; -using System.Threading.Channels; using System.Threading.Tasks; using mROA.Abstract; diff --git a/mROA/Implementation/Backend/UdpGateway.cs b/mROA/Implementation/Backend/UdpGateway.cs index d2642bb..1945e0f 100644 --- a/mROA/Implementation/Backend/UdpGateway.cs +++ b/mROA/Implementation/Backend/UdpGateway.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Threading; -using System.Threading.Channels; using System.Threading.Tasks; using mROA.Abstract; using static mROA.Implementation.EMessageType; diff --git a/mROA/Implementation/EndPointContext.cs b/mROA/Implementation/EndPointContext.cs index 1978f2c..5694614 100644 --- a/mROA/Implementation/EndPointContext.cs +++ b/mROA/Implementation/EndPointContext.cs @@ -1,4 +1,3 @@ -using System; using mROA.Abstract; using mROA.Implementation.Backend; diff --git a/mROA/Implementation/EventBinder.cs b/mROA/Implementation/EventBinder.cs index 8354c4f..429a882 100644 --- a/mROA/Implementation/EventBinder.cs +++ b/mROA/Implementation/EventBinder.cs @@ -1,10 +1,11 @@ using System; +using mROA.Abstract; -namespace mROA.Abstract +namespace mROA.Implementation { public class EventBinder : IEventBinder { - public Action BindAction { get; set; } + public Action BindAction { get; set; } = (_, _, _, _) => { }; public void BindEvents(T source, IEndPointContext context, IRepresentationModuleProducer representationModuleProducer, int index) diff --git a/mROA/Implementation/JsonSerializationToolkit.cs b/mROA/Implementation/JsonSerializationToolkit.cs deleted file mode 100644 index 38f8c19..0000000 --- a/mROA/Implementation/JsonSerializationToolkit.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Text.Json; -using mROA.Abstract; - -namespace mROA.Implementation -{ - // public class JsonSerializationToolkit : IContextualSerializationToolKit - // { - // public byte[] Serialize(T objectToSerialize) - // { - // return JsonSerializer.SerializeToUtf8Bytes(objectToSerialize); - // } - // - // public byte[] Serialize(object objectToSerialize, Type type) - // { - // return JsonSerializer.SerializeToUtf8Bytes(objectToSerialize, type); - // } - // - // public T? Deserialize(byte[] rawData) - // { - // return JsonSerializer.Deserialize(rawData); - // } - // - // public object? Deserialize(byte[] rawData, Type type) - // { - // return JsonSerializer.Deserialize(rawData, type); - // } - // - // public T? Deserialize(Span rawData) - // { - // return JsonSerializer.Deserialize(rawData); - // } - // - // public object? Deserialize(Span rawData, Type type) - // { - // return JsonSerializer.Deserialize(rawData, type); - // } - // - // public T Cast(object nonCasted) - // { - // return nonCasted switch - // { - // JsonElement jsonElement => jsonElement.Deserialize()!, - // T casted => casted, - // _ => throw new JsonException("Cannot cast object to type " + typeof(T).FullName) - // }; - // } - // - // public object Cast(object nonCasted, Type type) - // { - // if (nonCasted is JsonElement jsonElement) - // return jsonElement.Deserialize(type)!; - // - // throw new JsonException("Cannot cast object to type " + type.FullName); - // } - // - // public void Inject(T dependency) - // { - // } - // } -} \ No newline at end of file diff --git a/mROA/Implementation/MethodInvoker.cs b/mROA/Implementation/MethodInvoker.cs index ff713db..4f1e26c 100644 --- a/mROA/Implementation/MethodInvoker.cs +++ b/mROA/Implementation/MethodInvoker.cs @@ -36,7 +36,7 @@ namespace mROA.Implementation public bool IsTrusted { get; set; } = true; public Type[] ParameterTypes { get; set; } = Type.EmptyTypes; public Type? ReturnType { get; set; } - public Type SuitableType { get; set; } + public Type SuitableType { get; set; } = typeof(object); public Action> Invoking { get; set; } = (_, _, _, post) => { post.Invoke(null); }; diff --git a/mROA/Implementation/NetworkMessageHeader.cs b/mROA/Implementation/NetworkMessageHeader.cs index cb31c3e..0a0a271 100644 --- a/mROA/Implementation/NetworkMessageHeader.cs +++ b/mROA/Implementation/NetworkMessageHeader.cs @@ -1,7 +1,5 @@ using System; -using System.Text.Json.Serialization; using mROA.Abstract; -using mROA.Implementation.Attributes; // ReSharper disable UnusedMember.Global @@ -9,7 +7,7 @@ namespace mROA.Implementation { public class NetworkMessageHeader { - protected bool Equals(NetworkMessageHeader other) + private bool Equals(NetworkMessageHeader other) { return Id.Equals(other.Id) && MessageType == other.MessageType; } @@ -22,11 +20,6 @@ namespace mROA.Implementation return Equals((NetworkMessageHeader)obj); } - public override int GetHashCode() - { - return HashCode.Combine(Id, (int)MessageType); - } - public static readonly NetworkMessageHeader Null = new(); public NetworkMessageHeader() { @@ -43,13 +36,8 @@ namespace mROA.Implementation } public Guid Id { get; set; } - [JsonConverter(typeof(JsonStringEnumConverter))] public EMessageType MessageType { get; set; } public byte[] Data { get; set; } - - [JsonIgnore] - [SerializationIgnore] - public object Parced { get; set; } } } \ No newline at end of file diff --git a/mROA/Implementation/RemoteObjectBase.cs b/mROA/Implementation/RemoteObjectBase.cs index efcbeed..3410e97 100644 --- a/mROA/Implementation/RemoteObjectBase.cs +++ b/mROA/Implementation/RemoteObjectBase.cs @@ -1,5 +1,4 @@ using System; -using System.Net; using System.Threading; using System.Threading.Tasks; using mROA.Abstract; diff --git a/mROA/Implementation/RepresentationModule.cs b/mROA/Implementation/RepresentationModule.cs index bb9d40c..d406d59 100644 --- a/mROA/Implementation/RepresentationModule.cs +++ b/mROA/Implementation/RepresentationModule.cs @@ -5,6 +5,7 @@ using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using mROA.Abstract; +#pragma warning disable CS8602 // Dereference of a possibly null reference. namespace mROA.Implementation {