diff --git a/CoreRemoting.Tests/DicTests.cs b/CoreRemoting.Tests/DicTests.cs index 6626f8a..85a5cb3 100644 --- a/CoreRemoting.Tests/DicTests.cs +++ b/CoreRemoting.Tests/DicTests.cs @@ -158,7 +158,7 @@ public async Task Register_multiple_services_thread_safety() var t = new ConcurrentDictionary(); void RegisterCurrentThread() => - t.TryAdd(Thread.CurrentThread.ManagedThreadId, 0); + t.TryAdd(Environment.CurrentManagedThreadId, 0); void RegisterService() { diff --git a/CoreRemoting.Tests/RpcTests.cs b/CoreRemoting.Tests/RpcTests.cs index 34facba..dd1bd65 100644 --- a/CoreRemoting.Tests/RpcTests.cs +++ b/CoreRemoting.Tests/RpcTests.cs @@ -517,6 +517,8 @@ public void Missing_method_throws_RemoteInvocationException() // a localized message similar to "Method 'Missing method' not found" Assert.NotNull(ex); Assert.Contains("Missing Method", ex.Message); + + Console.WriteLine(_serverFixture.LastServerError); Assert.Equal(0, _serverFixture.ServerErrorCount); } diff --git a/CoreRemoting.Tests/ServerFixture.cs b/CoreRemoting.Tests/ServerFixture.cs index 18cf117..88aa856 100644 --- a/CoreRemoting.Tests/ServerFixture.cs +++ b/CoreRemoting.Tests/ServerFixture.cs @@ -11,6 +11,8 @@ public class ServerFixture : IDisposable { public int ServerErrorCount; + public Exception LastServerError; + public ServerFixture() { TestService = new TestService(); @@ -98,8 +100,9 @@ public void Start(IServerChannel channel = null) ServerConfig.Channel = channel; Server = new RemotingServer(ServerConfig); - Server.Error += (_, _) => + Server.Error += (s, ex) => { + LastServerError = ex; ServerErrorCount++; }; diff --git a/CoreRemoting.Tests/SessionTests.cs b/CoreRemoting.Tests/SessionTests.cs index 272f7f0..1b2d223 100644 --- a/CoreRemoting.Tests/SessionTests.cs +++ b/CoreRemoting.Tests/SessionTests.cs @@ -195,7 +195,6 @@ public void RemotingSession_should_be_accessible_to_the_component_constructor() } [Fact] - [SuppressMessage("Usage", "xUnit1030:Do not call ConfigureAwait in test method", Justification = "")] public async Task CloseSession_method_should_close_session_gracefully_issue55() { using var client = new RemotingClient(new ClientConfig() diff --git a/CoreRemoting/CoreRemoting.csproj b/CoreRemoting/CoreRemoting.csproj index 1dc75da..f5ca7d7 100644 --- a/CoreRemoting/CoreRemoting.csproj +++ b/CoreRemoting/CoreRemoting.csproj @@ -59,7 +59,7 @@ - + diff --git a/CoreRemoting/RemoteDelegates/EventStub.cs b/CoreRemoting/RemoteDelegates/EventStub.cs index f0d5653..32f1379 100644 --- a/CoreRemoting/RemoteDelegates/EventStub.cs +++ b/CoreRemoting/RemoteDelegates/EventStub.cs @@ -277,7 +277,7 @@ private Delegate Delegate set { TypedDelegate = (T)(object)value; } } - private object syncRoot = new object(); + private object syncRoot = new(); public void AddHandler(Delegate handler) { @@ -396,9 +396,8 @@ public static int GetHandlerCount(Delegate handler) foreach (var d in handler.GetInvocationList()) { // check if it's a delegate holder - if (d.Target is IDelegateHolder) + if (d.Target is IDelegateHolder holder) { - var holder = (IDelegateHolder)d.Target; count += holder.HandlerCount; continue; } diff --git a/CoreRemoting/RemotingServer.cs b/CoreRemoting/RemotingServer.cs index 2dab19f..16ace12 100644 --- a/CoreRemoting/RemotingServer.cs +++ b/CoreRemoting/RemotingServer.cs @@ -25,8 +25,7 @@ public sealed class RemotingServer : IRemotingServer private readonly string _uniqueServerInstanceName; // ReSharper disable once InconsistentNaming - private static readonly ConcurrentDictionary _serverInstances = - new ConcurrentDictionary(); + private static readonly ConcurrentDictionary _serverInstances = new(); private static WeakReference _defaultRemotingServerRef; diff --git a/CoreRemoting/ServiceProxy.cs b/CoreRemoting/ServiceProxy.cs index e5a551e..cac82ff 100644 --- a/CoreRemoting/ServiceProxy.cs +++ b/CoreRemoting/ServiceProxy.cs @@ -261,8 +261,9 @@ private bool MapLinqExpressionArgument(Type argumentType, object argument, out o argumentType is { IsGenericType: true, - BaseType: { IsGenericType: true } - } && argumentType.BaseType.GetGenericTypeDefinition() == typeof(Expression<>); + BaseType.IsGenericType: true + } + && argumentType.BaseType.GetGenericTypeDefinition() == typeof(Expression<>); if (!isLinqExpression) {