diff --git a/src/Menees.Remoting/Json/ReadOnlyDictionaryConverter.cs b/src/Menees.Remoting/Json/ReadOnlyDictionaryConverter.cs index 8d63058..2f8fc25 100644 --- a/src/Menees.Remoting/Json/ReadOnlyDictionaryConverter.cs +++ b/src/Menees.Remoting/Json/ReadOnlyDictionaryConverter.cs @@ -96,7 +96,7 @@ private class ReadOnlyDictionaryConverterInner : JsonConverter SendAsync(TIn message, CancellationToken cancellationTok { Request request = new() { - Arguments = new() { new UserSerializedValue(typeof(TIn), message, this.UserSerializer) }, + Arguments = [new UserSerializedValue(typeof(TIn), message, this.UserSerializer)], }; Response? response = null; diff --git a/src/Menees.Remoting/Models/ServiceError.cs b/src/Menees.Remoting/Models/ServiceError.cs index 3a70d1e..405cfea 100644 --- a/src/Menees.Remoting/Models/ServiceError.cs +++ b/src/Menees.Remoting/Models/ServiceError.cs @@ -74,10 +74,10 @@ private Exception CreateException() // Try to throw a new exception of the requested type. The new exception's StackTrace will be from the client, // but its message, data type, and inner exception will match the server's exception info. Exception result; - ConstructorInfo? constructor = this.ExceptionType.GetConstructor(new[] { typeof(string), typeof(Exception) }); + ConstructorInfo? constructor = this.ExceptionType.GetConstructor([typeof(string), typeof(Exception)]); if (constructor != null) { - result = (Exception)constructor.Invoke(new object?[] { this.Message, innerException }); + result = (Exception)constructor.Invoke([this.Message, innerException]); } else { diff --git a/src/Menees.Remoting/Pipes/PipeClient.cs b/src/Menees.Remoting/Pipes/PipeClient.cs index a51a1b2..88bbde5 100644 --- a/src/Menees.Remoting/Pipes/PipeClient.cs +++ b/src/Menees.Remoting/Pipes/PipeClient.cs @@ -13,7 +13,7 @@ internal sealed class PipeClient : PipeNode #region Private Data Members #pragma warning disable SA1310 // Field names should not contain underscore. Named like WinError.h constant. - private const int ERROR_SEM_TIMEOUT = unchecked((int)0x80070079); + private const int ERROR_SEM_TIMEOUT = unchecked((int)0x80_07_00_79); #pragma warning restore SA1310 // Field names should not contain underscore private readonly PipeClientSecurity? security; diff --git a/src/Menees.Remoting/Pipes/PipeServer.cs b/src/Menees.Remoting/Pipes/PipeServer.cs index ab83005..dbf2600 100644 --- a/src/Menees.Remoting/Pipes/PipeServer.cs +++ b/src/Menees.Remoting/Pipes/PipeServer.cs @@ -11,7 +11,7 @@ internal sealed class PipeServer : PipeNode { #region Private Data Members - private readonly HashSet listeners = new(); + private readonly HashSet listeners = []; private readonly int minListeners; private readonly int maxListeners; private readonly IServer server; diff --git a/src/Menees.Remoting/RmiServer.cs b/src/Menees.Remoting/RmiServer.cs index 109241e..ca99eac 100644 --- a/src/Menees.Remoting/RmiServer.cs +++ b/src/Menees.Remoting/RmiServer.cs @@ -135,7 +135,7 @@ protected override void Dispose(bool disposing) private static Dictionary CreateMethodSignatureDictionary() { - List<(string Signature, MethodInfo Method)> items = new(); + List<(string Signature, MethodInfo Method)> items = []; void AddMethods(Type interfaceType) { diff --git a/src/Menees.Remoting/ServerHost.cs b/src/Menees.Remoting/ServerHost.cs index 73b2f18..5383b3b 100644 --- a/src/Menees.Remoting/ServerHost.cs +++ b/src/Menees.Remoting/ServerHost.cs @@ -15,7 +15,7 @@ public sealed class ServerHost : IServerHost, IDisposable #region Private Data Members private readonly ManualResetEventSlim resetEvent = new(false); - private readonly HashSet servers = new(); + private readonly HashSet servers = []; private bool isDisposed; private bool isExiting; diff --git a/tests/Menees.Remoting.Tests/BaseTests.cs b/tests/Menees.Remoting.Tests/BaseTests.cs index db8fc08..056dd41 100644 --- a/tests/Menees.Remoting.Tests/BaseTests.cs +++ b/tests/Menees.Remoting.Tests/BaseTests.cs @@ -149,12 +149,12 @@ private protected static void TestProxy(ITester testerProxy, int testId, bool is Widget paper = testerProxy.CreateWidget("Paper", 0.01m, 85, 110); paper.Name.ShouldBe("Paper"); paper.Cost.ShouldBe(0.01m); - paper.Dimensions.ShouldBe(new[] { 85, 110 }); + paper.Dimensions.ShouldBe([85, 110]); paper = testerProxy.UpdateWidget(paper, "Fancy Paper", 0.02m, null); paper.Name.ShouldBe("Fancy Paper"); paper.Cost.ShouldBe(0.02m); - paper.Dimensions.ShouldBe(new[] { 85, 110 }); + paper.Dimensions.ShouldBe([85, 110]); } private protected static void WriteUnhandledServerException(Exception ex) @@ -168,12 +168,14 @@ private static void InitializeProcessStartInfo(Type hostProgram, out ProcessStar { string hostExeLocation = hostProgram.Assembly.Location; - startInfo = new(); - startInfo.CreateNoWindow = true; - startInfo.WindowStyle = ProcessWindowStyle.Hidden; - startInfo.ErrorDialog = false; + startInfo = new() + { + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden, + ErrorDialog = false, + }; - arguments = new(); + arguments = []; if (string.Equals(Path.GetExtension(hostExeLocation), ".exe", StringComparison.OrdinalIgnoreCase)) { startInfo.FileName = Path.GetFileName(hostExeLocation); diff --git a/tests/Menees.Remoting.Tests/MessageNodeTests.cs b/tests/Menees.Remoting.Tests/MessageNodeTests.cs index ecdf1ab..b5162ae 100644 --- a/tests/Menees.Remoting.Tests/MessageNodeTests.cs +++ b/tests/Menees.Remoting.Tests/MessageNodeTests.cs @@ -24,7 +24,7 @@ public async Task Base64ExampleAsync() server.Start(); using MessageClient client = new(ServerPath); - string response = await client.SendAsync(new byte[] { 1, 2, 3, 4 }).ConfigureAwait(false); + string response = await client.SendAsync([1, 2, 3, 4]).ConfigureAwait(false); response.ShouldBe("AQIDBA=="); } diff --git a/tests/Menees.Remoting.Tests/RmiClientTests.cs b/tests/Menees.Remoting.Tests/RmiClientTests.cs index 8dcfdbd..c18db98 100644 --- a/tests/Menees.Remoting.Tests/RmiClientTests.cs +++ b/tests/Menees.Remoting.Tests/RmiClientTests.cs @@ -16,7 +16,7 @@ public void HasherExample() using RmiClient client = new(ServerPath); IHasher proxy = client.CreateProxy(); - proxy.Hash(new byte[] { 1, 2, 3, 4 }).Length.ShouldBe(20); + proxy.Hash([1, 2, 3, 4]).Length.ShouldBe(20); proxy.Hash("Testing").ShouldBe("0820b32b206b7352858e8903a838ed14319acdfd"); }