diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index c018944..0000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ConsoleApplication1/ConsoleApplication1.csproj b/ConsoleApplication1/ConsoleApplication1.csproj index e8d17ab..dbc2485 100644 --- a/ConsoleApplication1/ConsoleApplication1.csproj +++ b/ConsoleApplication1/ConsoleApplication1.csproj @@ -1,76 +1,12 @@ - - - + - Debug - AnyCPU - {9C8FF3F3-C560-4390-A113-3A5220F02E15} + net48;net6.0 + ..\bin Exe - Properties - ConsoleApplication1 - ConsoleApplication1 - v4.5 - 512 + false - - AnyCPU - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - true - - - AnyCPU - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - true - - - - - - - - - - - - - - - - - - - - - Designer - - - - {377C04C5-EE8C-4159-BDDC-37F1A8372705} - SharpRemote.Test - - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - + + - - \ No newline at end of file diff --git a/Samples/SampleBrowser/SampleBrowser.csproj b/Samples/SampleBrowser/SampleBrowser.csproj index 08940d6..ccd23c0 100644 --- a/Samples/SampleBrowser/SampleBrowser.csproj +++ b/Samples/SampleBrowser/SampleBrowser.csproj @@ -1,180 +1,72 @@ - - - - - Debug - AnyCPU - {4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2} - WinExe - Properties - SampleBrowser - SampleBrowser - v4.5 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - AnyCPU - true - full - false - ..\..\bin\win\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - ..\..\bin\win\ - TRACE - prompt - 4 - - - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - - - - - BluetoothView.xaml - - - - - HostView.xaml - - - - - - InProcessHostView.xaml - - - - - - - - - - - - LongTermView.xaml - - - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - {41f098da-29dc-48af-9c6c-2bc6f4f0be41} - SharpRemote.Bluetooth - - - {377C04C5-EE8C-4159-BDDC-37F1A8372705} - SharpRemote.Test - - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - - - - - + + + net48 + ..\..\bin + Exe + false + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + \ No newline at end of file diff --git a/Samples/SampleBrowser/packages.config b/Samples/SampleBrowser/packages.config deleted file mode 100644 index 6419ef8..0000000 --- a/Samples/SampleBrowser/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Samples/SampleLibrary/NativeResource/IErrorListener.cs b/Samples/SampleLibrary/NativeResource/IErrorListener.cs deleted file mode 100644 index 528aa97..0000000 --- a/Samples/SampleLibrary/NativeResource/IErrorListener.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace SampleLibrary.NativeResource -{ - public interface IErrorListener - { - void ReportError(string error); - } -} \ No newline at end of file diff --git a/Samples/SampleLibrary/NativeResource/IUsesNativeResource.cs b/Samples/SampleLibrary/NativeResource/IUsesNativeResource.cs deleted file mode 100644 index ed24332..0000000 --- a/Samples/SampleLibrary/NativeResource/IUsesNativeResource.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace SampleLibrary.NativeResource -{ - public interface IUsesNativeResource - { - void Load(string path); - - string CurrentPath { get; } - - double CalculateTheMeaningOfEverything(); - - Metadata Metadata { get; } - - /// - /// Adds a listener to this object. - /// - /// - /// We tell SharpRemote that the parameter is to be marshalled by reference - /// instead of the default by value. This means that instead of serializing that object, a servant is created - /// on-the-fly while the actual implementation of this interface is called with a proxy that itself - /// marshalls all calls to the other side. - /// - /// - void AddListener(IErrorListener listener); - - /// - /// Removes the given listener from this object or does nothing if it hasn't been registered. - /// - /// - void RemoveListener(IErrorListener listener); - } -} \ No newline at end of file diff --git a/Samples/SampleLibrary/NativeResource/Metadata.cs b/Samples/SampleLibrary/NativeResource/Metadata.cs deleted file mode 100644 index 83c974a..0000000 --- a/Samples/SampleLibrary/NativeResource/Metadata.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.Serialization; - -namespace SampleLibrary.NativeResource -{ - /// - /// Example of a custom class that can be seamlessly marshalled across processes. - /// - [DataContract] - public class Metadata - { - [DataMember] - public string FileName { get; set; } - - [DataMember] - public long FileSize { get; set; } - } -} \ No newline at end of file diff --git a/Samples/SampleLibrary/NativeResource/UsesNativeResource.cs b/Samples/SampleLibrary/NativeResource/UsesNativeResource.cs deleted file mode 100644 index 90ec578..0000000 --- a/Samples/SampleLibrary/NativeResource/UsesNativeResource.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace SampleLibrary.NativeResource -{ - /// - /// An example class that uses a native resource that, due to depending on - /// a legacy software, can only be executed within an x86 environment. - /// - public sealed class UsesNativeResource - : IUsesNativeResource - { - public UsesNativeResource() - { - if (Environment.Is64BitProcess) - throw new NotSupportedException("Can only executed under 32bit!"); - } - - public void Load(string path) - { - throw new NotImplementedException(); - } - - public string CurrentPath - { - get { throw new NotImplementedException(); } - } - - public double CalculateTheMeaningOfEverything() - { - throw new NotImplementedException(); - } - - public Metadata Metadata - { - get { throw new NotImplementedException(); } - } - - public void AddListener(IErrorListener listener) - { - throw new NotImplementedException(); - } - - public void RemoveListener(IErrorListener listener) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Samples/SampleLibrary/SampleLibrary.csproj b/Samples/SampleLibrary/SampleLibrary.csproj deleted file mode 100644 index 072e4a5..0000000 --- a/Samples/SampleLibrary/SampleLibrary.csproj +++ /dev/null @@ -1,52 +0,0 @@ - - - - - Debug - AnyCPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6} - Library - Properties - SampleLibrary - SampleLibrary - v4.5 - 512 - - - true - full - false - bin\win\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\win\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpRemote.Bluetooth/EndPoints/Bluetooth/BluetoothRemotingEndPoint.cs b/SharpRemote.Bluetooth/EndPoints/Bluetooth/BluetoothRemotingEndPoint.cs index e7c5bf7..db00ac3 100644 --- a/SharpRemote.Bluetooth/EndPoints/Bluetooth/BluetoothRemotingEndPoint.cs +++ b/SharpRemote.Bluetooth/EndPoints/Bluetooth/BluetoothRemotingEndPoint.cs @@ -4,7 +4,6 @@ using InTheHand.Net; using InTheHand.Net.Bluetooth; using InTheHand.Net.Sockets; -using SharpRemote.EndPoints.Sockets; // ReSharper disable CheckNamespace namespace SharpRemote diff --git a/SharpRemote.Bluetooth/SharpRemote.Bluetooth.csproj b/SharpRemote.Bluetooth/SharpRemote.Bluetooth.csproj index af08f77..f471998 100644 --- a/SharpRemote.Bluetooth/SharpRemote.Bluetooth.csproj +++ b/SharpRemote.Bluetooth/SharpRemote.Bluetooth.csproj @@ -1,72 +1,13 @@ - - - + - Debug - AnyCPU - {41F098DA-29DC-48AF-9C6C-2BC6F4F0BE41} - Library - Properties - SharpRemote - SharpRemote.Bluetooth - v4.5 - 512 - + net48 + ..\bin + false - - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - ..\bin\win\SharpRemote.Bluetooth.XML - true - - - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - ..\bin\win\SharpRemote.Bluetooth.XML - true - - - - ..\packages\32feet.NET.3.5.0.0\lib\net\InTheHand.Net.Personal.dll - True - - - - - - - - - - - - - - - + - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - + - - \ No newline at end of file diff --git a/SharpRemote.Bluetooth/packages.config b/SharpRemote.Bluetooth/packages.config deleted file mode 100644 index a2899e3..0000000 --- a/SharpRemote.Bluetooth/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/SharpRemote.Host.FailsStartup/SharpRemote.Host.FailsStartup.csproj b/SharpRemote.Host.FailsStartup/SharpRemote.Host.FailsStartup.csproj index 308ba50..1edb657 100644 --- a/SharpRemote.Host.FailsStartup/SharpRemote.Host.FailsStartup.csproj +++ b/SharpRemote.Host.FailsStartup/SharpRemote.Host.FailsStartup.csproj @@ -1,66 +1,11 @@ - - - + - Debug - AnyCPU - {C0C2492B-E3E3-49E2-BA97-76CB07C3F473} + net48;net6.0 + ..\bin Exe - Properties - SharpRemote.Host.FailsStartup - SharpRemote.Host.FailsStartup - v4.5 - 512 + false - - AnyCPU - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - true - - - AnyCPU - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - true - - - - - - - - - - - - - - - - - - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - + - - \ No newline at end of file diff --git a/SharpRemote.Host/Program.cs b/SharpRemote.Host/Program.cs index 6373614..1371615 100644 --- a/SharpRemote.Host/Program.cs +++ b/SharpRemote.Host/Program.cs @@ -6,6 +6,7 @@ using SharpRemote.Hosting; using log4net; using log4net.Config; +using SharpRemote.CodeGeneration; namespace SharpRemote.Host { @@ -18,7 +19,11 @@ private static void Main(string[] args) try { GlobalContext.Properties["pid"] = Process.GetCurrentProcess().Id; - XmlConfigurator.Configure(new FileInfo("SharpRemote.Host.exe.config")); + var log4NetConfigFileInfo = new FileInfo("SharpRemote.Host.exe.config"); + if (!log4NetConfigFileInfo.Exists) + log4NetConfigFileInfo = new FileInfo("SharpRemote.Host.dll.config"); + + XmlConfigurator.Configure(log4NetConfigFileInfo); AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; @@ -26,6 +31,7 @@ private static void Main(string[] args) { silo.Run(IPAddress.Loopback); } + } catch (Exception e) { diff --git a/SharpRemote.Host/SharpRemote.Host.csproj b/SharpRemote.Host/SharpRemote.Host.csproj index 18db913..927caf1 100644 --- a/SharpRemote.Host/SharpRemote.Host.csproj +++ b/SharpRemote.Host/SharpRemote.Host.csproj @@ -1,101 +1,14 @@ - - - + - Debug - AnyCPU - {21218E92-3815-4E5E-9761-C3FB0709F532} + net48;net6.0 + ..\bin Exe - Properties - SharpRemote.Host - SharpRemote.Host - v4.5 - 512 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true + false - - AnyCPU - true - full - false - ..\bin\win\ - TRACE;DEBUG - prompt - 4 - true - - - AnyCPU - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - true - - - SharpRemote.Host.Program - - - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - - - - - Designer - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - + - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - + - - \ No newline at end of file diff --git a/SharpRemote.Host/packages.config b/SharpRemote.Host/packages.config deleted file mode 100644 index 6419ef8..0000000 --- a/SharpRemote.Host/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/SharpRemote.NETCore/SharpRemote.NETCore.csproj b/SharpRemote.NETCore/SharpRemote.NETCore.csproj deleted file mode 100644 index dd79b52..0000000 --- a/SharpRemote.NETCore/SharpRemote.NETCore.csproj +++ /dev/null @@ -1,313 +0,0 @@ - - - - netcoreapp3.0 - SharpRemote - SharpRemote - - - - ..\bin\ - TRACE;DOTNETCORE - - - - TRACE;DOTNETCORE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SharpRemote.SystemTest/AssemblySetup.cs b/SharpRemote.SystemTest/AssemblySetup.cs index fd7d00f..3adec2d 100644 --- a/SharpRemote.SystemTest/AssemblySetup.cs +++ b/SharpRemote.SystemTest/AssemblySetup.cs @@ -11,7 +11,7 @@ public sealed class AssemblySetup [OneTimeSetUp] public void OneTimeSetUp() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; + string codeBase = Assembly.GetExecutingAssembly().Location; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); var directory = Path.GetDirectoryName(path); diff --git a/SharpRemote.SystemTest/Hosting/HeartbeatMonitorTest.cs b/SharpRemote.SystemTest/Hosting/HeartbeatMonitorTest.cs index a61f091..dd878cd 100644 --- a/SharpRemote.SystemTest/Hosting/HeartbeatMonitorTest.cs +++ b/SharpRemote.SystemTest/Hosting/HeartbeatMonitorTest.cs @@ -117,7 +117,7 @@ public void TestCtor2() locEndPoint: _localEndPoint, remoteEndPoint: _remoteEndPoint)) .Should().Throw() - .WithMessage("Value cannot be null.\r\nParameter name: heartbeat"); + .WithMessage("Value cannot be null*Parameter*heartbeat*"); } [Test] @@ -136,7 +136,7 @@ public void TestCtor3() locEndPoint: _localEndPoint, remoteEndPoint: _remoteEndPoint)) .Should().Throw() - .WithMessage("Value cannot be null.\r\nParameter name: debugger"); + .WithMessage("Value cannot be null*Parameter*debugger*"); } [Test] @@ -154,7 +154,7 @@ public void TestCtor4() locEndPoint: _localEndPoint, remoteEndPoint: _remoteEndPoint)) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: heartBeatInterval"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*heartBeatInterval*"); } [Test] @@ -172,7 +172,7 @@ public void TestCtor5() locEndPoint: _localEndPoint, remoteEndPoint: _remoteEndPoint)) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: failureThreshold"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*failureThreshold*"); } [Test] diff --git a/SharpRemote.SystemTest/OutOfProcessSilo/CtorTest.cs b/SharpRemote.SystemTest/OutOfProcessSilo/CtorTest.cs index 17b2ca5..f5d3a6a 100644 --- a/SharpRemote.SystemTest/OutOfProcessSilo/CtorTest.cs +++ b/SharpRemote.SystemTest/OutOfProcessSilo/CtorTest.cs @@ -74,19 +74,19 @@ public void TestCtor6() { new Action(() => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { HeartbeatSettings = { Interval = TimeSpan.Zero } })) .Should().Throw() - .WithMessage("The heartbeat interval must be greater than zero\r\nParameter name: heartbeatSettings.Interval"); + .WithMessage("The heartbeat interval must be greater than zero*Parameter*heartbeatSettings.Interval*"); new Action(() => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings{HeartbeatSettings = { Interval = TimeSpan.FromSeconds(-1) }})) .Should().Throw() - .WithMessage("The heartbeat interval must be greater than zero\r\nParameter name: heartbeatSettings.Interval"); + .WithMessage("The heartbeat interval must be greater than zero*Parameter*heartbeatSettings.Interval*"); new Action(() => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { HeartbeatSettings = { SkippedHeartbeatThreshold = 0} })) .Should().Throw() - .WithMessage("The skipped heartbeat threshold must be greater than zero\r\nParameter name: heartbeatSettings.SkippedHeartbeatThreshold"); + .WithMessage("The skipped heartbeat threshold must be greater than zero*Parameter*heartbeatSettings.SkippedHeartbeatThreshold*"); new Action(() => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { HeartbeatSettings = { SkippedHeartbeatThreshold = -1 } })) .Should().Throw() - .WithMessage("The skipped heartbeat threshold must be greater than zero\r\nParameter name: heartbeatSettings.SkippedHeartbeatThreshold"); + .WithMessage("The skipped heartbeat threshold must be greater than zero*Parameter*heartbeatSettings.SkippedHeartbeatThreshold*"); } [Test] @@ -96,19 +96,19 @@ public void TestCtor7() new Action( () => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { EndPointConnectTimeout = TimeSpan.FromSeconds(-1) })) .Should().Throw() - .WithMessage("EndPointConnectTimeout should be greater than zero\r\nParameter name: failureSettings"); + .WithMessage("EndPointConnectTimeout should be greater than zero*Parameter*failureSettings*"); new Action( () => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { EndPointConnectTimeout = TimeSpan.Zero })) .Should().Throw() - .WithMessage("EndPointConnectTimeout should be greater than zero\r\nParameter name: failureSettings"); + .WithMessage("EndPointConnectTimeout should be greater than zero*Parameter*failureSettings*"); new Action( () => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { ProcessReadyTimeout = TimeSpan.FromSeconds(-1) })) .Should().Throw() - .WithMessage("ProcessReadyTimeout should be greater than zero\r\nParameter name: failureSettings"); + .WithMessage("ProcessReadyTimeout should be greater than zero*Parameter*failureSettings*"); new Action( () => new SharpRemote.Hosting.OutOfProcessSilo(failureSettings: new FailureSettings { ProcessReadyTimeout = TimeSpan.Zero })) .Should().Throw() - .WithMessage("ProcessReadyTimeout should be greater than zero\r\nParameter name: failureSettings"); + .WithMessage("ProcessReadyTimeout should be greater than zero*Parameter*failureSettings*"); } } diff --git a/SharpRemote.SystemTest/OutOfProcessSilo/FailureDetectionTest.cs b/SharpRemote.SystemTest/OutOfProcessSilo/FailureDetectionTest.cs index 1dfcb10..af1e168 100644 --- a/SharpRemote.SystemTest/OutOfProcessSilo/FailureDetectionTest.cs +++ b/SharpRemote.SystemTest/OutOfProcessSilo/FailureDetectionTest.cs @@ -164,6 +164,10 @@ public void TestFailureDetection11() )] public void TestFailureDetection2() { + #if NET6_0 + Assert.Inconclusive("Thread aborting not support in .NET 6.0"); + #endif + Failure? failure = null; Decision? decision = null; Resolution? resolution = null; diff --git a/SharpRemote.SystemTest/OutOfProcessSilo/StartTest.cs b/SharpRemote.SystemTest/OutOfProcessSilo/StartTest.cs index 7297a2f..c4e241b 100644 --- a/SharpRemote.SystemTest/OutOfProcessSilo/StartTest.cs +++ b/SharpRemote.SystemTest/OutOfProcessSilo/StartTest.cs @@ -52,7 +52,7 @@ public void TestStart2() new Action(silo.Start) .Should().Throw() - .WithMessage("The system cannot find the file specified"); + .WithMessage("*The system cannot find the file specified*"); silo.IsProcessRunning.Should().BeFalse("because we shouldn't have been able to start the process"); silo.HasProcessFailed.Should().BeFalse(); @@ -72,7 +72,7 @@ public void TestStart3() new Action(silo.Start) .Should().Throw() - .WithMessage("The specified executable is not a valid application for this OS platform."); + .WithMessage("*The specified executable is not a valid application for this OS platform."); silo.IsProcessRunning.Should().BeFalse(); silo.HasProcessFailed.Should().BeFalse(); diff --git a/SharpRemote.SystemTest/ServiceDiscovery/NetworkServiceDiscovererTest.cs b/SharpRemote.SystemTest/ServiceDiscovery/NetworkServiceDiscovererTest.cs index 683986f..1664571 100644 --- a/SharpRemote.SystemTest/ServiceDiscovery/NetworkServiceDiscovererTest.cs +++ b/SharpRemote.SystemTest/ServiceDiscovery/NetworkServiceDiscovererTest.cs @@ -36,7 +36,7 @@ public void TestRegisterTooBig() { new Action(() => _discoverer.RegisterService("dawwdawd", new IPEndPoint(IPAddress.Any, 0), new byte[500])) .Should().Throw() - .WithMessage("The total size of a message may not exceed 512 bytes (this message would be 568 bytes in length)\r\nParameter name: payload"); + .WithMessage("The total size of a message may not exceed 512 bytes (this message would be 568 bytes in length)*Parameter*payload*"); } //[Test] diff --git a/SharpRemote.SystemTest/SharpRemote.SystemTest.csproj b/SharpRemote.SystemTest/SharpRemote.SystemTest.csproj index b836f98..9fc105d 100644 --- a/SharpRemote.SystemTest/SharpRemote.SystemTest.csproj +++ b/SharpRemote.SystemTest/SharpRemote.SystemTest.csproj @@ -1,121 +1,24 @@ - - - - + - Debug - AnyCPU - {792694CE-6935-4452-9F3C-319ADAA87A26} - Library - Properties - SharpRemote.SystemTest - SharpRemote.SystemTest - v4.5 - 512 - - + net48;net6.0 + ..\bin + false - - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - true - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\FluentAssertions.5.10.3\lib\net45\FluentAssertions.dll - - - ..\packages\FluentAssertions.Extensions.1.0.18\lib\net45\FluentAssertions.Extensions.dll - - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - ..\packages\Moq.4.16.1\lib\net45\Moq.dll - - - ..\packages\NUnit.3.13.2\lib\net45\nunit.framework.dll - - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - {377C04C5-EE8C-4159-BDDC-37F1A8372705} - SharpRemote.Test - - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - + + + + + + + + + + + - - + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/SharpRemote.SystemTest/packages.config b/SharpRemote.SystemTest/packages.config deleted file mode 100644 index 39d43aa..0000000 --- a/SharpRemote.SystemTest/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpRemote.Test/AssemblySetup.cs b/SharpRemote.Test/AssemblySetup.cs index b6eb30c..8f666fb 100644 --- a/SharpRemote.Test/AssemblySetup.cs +++ b/SharpRemote.Test/AssemblySetup.cs @@ -11,7 +11,7 @@ public sealed class AssemblySetup [OneTimeSetUp] public void OneTimeSetUp() { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; + string codeBase = Assembly.GetExecutingAssembly().Location; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); var directory = Path.GetDirectoryName(path); diff --git a/SharpRemote.Test/CodeGeneration/FailureHandling/ProxyCreatorTest.cs b/SharpRemote.Test/CodeGeneration/FailureHandling/ProxyCreatorTest.cs index 244723f..cd9407c 100644 --- a/SharpRemote.Test/CodeGeneration/FailureHandling/ProxyCreatorTest.cs +++ b/SharpRemote.Test/CodeGeneration/FailureHandling/ProxyCreatorTest.cs @@ -27,25 +27,11 @@ private ProxyCreator Create() public void Setup() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.FaultTolerance"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); string moduleName = assemblyName.Name + ".dll"; _module = _assembly.DefineDynamicModule(moduleName); } - public void Save() - { - var fname = "SharpRemote.GeneratedCode.FaultTolerance.dll"; - try - { - _assembly.Save(fname); - TestContext.Out.WriteLine("Assembly written to: {0}", Path.Combine(Directory.GetCurrentDirectory(), fname)); - } - catch (Exception e) - { - TestContext.Out.WriteLine("Couldn't write assembly: {0}", e); - } - } - #region Timeouts [Test] @@ -60,7 +46,6 @@ public void TestIReturnsIntTaskMethodStringTimeout1() var proxy = creator.PrepareProxyFor(subject.Object) .WithMaximumLatencyOf(TimeSpan.FromSeconds(10)) .Create(); - Save(); Await(proxy.CreateFile("simon")).Should().Be(-21321211); subject.Verify(x => x.CreateFile("simon"), Times.Once); @@ -476,8 +461,6 @@ public void TestIReturnsIntTaskDefaultFallback() var proxy = creator.PrepareProxyFor(subject.Object) .WithDefaultFallback() .Create(); - Save(); - proxy.DoStuff(); subject.Verify(x => x.DoStuff(), Times.Once); diff --git a/SharpRemote.Test/CodeGeneration/Remoting/RemotingProxyCreatorTest.cs b/SharpRemote.Test/CodeGeneration/Remoting/RemotingProxyCreatorTest.cs index 18df1ae..d6b555a 100644 --- a/SharpRemote.Test/CodeGeneration/Remoting/RemotingProxyCreatorTest.cs +++ b/SharpRemote.Test/CodeGeneration/Remoting/RemotingProxyCreatorTest.cs @@ -34,7 +34,7 @@ public sealed class RemotingProxyCreatorTest public void SetUp() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Proxies"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); _moduleName = assemblyName.Name + ".dll"; ModuleBuilder module = _assembly.DefineDynamicModule(_moduleName); @@ -47,12 +47,6 @@ public void SetUp() _creator = new RemotingProxyCreator(module); } - [OneTimeTearDown] - public void TearDown() - { - _assembly.Save(_moduleName); - } - private T TestGenerate() { Type type = null; diff --git a/SharpRemote.Test/CodeGeneration/Remoting/ServantCreatorTest.cs b/SharpRemote.Test/CodeGeneration/Remoting/ServantCreatorTest.cs index 17b4a75..d889565 100644 --- a/SharpRemote.Test/CodeGeneration/Remoting/ServantCreatorTest.cs +++ b/SharpRemote.Test/CodeGeneration/Remoting/ServantCreatorTest.cs @@ -25,7 +25,7 @@ public sealed class ServantCreatorTest public void SetUp() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Servants"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); _moduleName = assemblyName.Name + ".dll"; ModuleBuilder module = _assembly.DefineDynamicModule(_moduleName); @@ -47,12 +47,6 @@ public void SetUp() private string _moduleName; private ISerializer _serializer; - [OneTimeTearDown] - public void TearDown() - { - _assembly.Save(_moduleName); - } - private IServant TestGenerate(T subject) { Type type = null; diff --git a/SharpRemote.Test/CodeGeneration/Serialization/AbstractSerializerAcceptanceTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/AbstractSerializerAcceptanceTest.cs index bc9e19a..02d271f 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/AbstractSerializerAcceptanceTest.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/AbstractSerializerAcceptanceTest.cs @@ -16,7 +16,6 @@ namespace SharpRemote.Test.CodeGeneration.Serialization public abstract class AbstractSerializerAcceptanceTest { protected abstract ISerializer2 Create(); - protected abstract void Save(); public static IEnumerable GrainIds => new ulong[] { @@ -1656,7 +1655,6 @@ private void MethodCallRoundtripObject(T value) using (var stream = new MemoryStream()) { serializer.RegisterType(); - Save(); using (var writer = serializer.CreateMethodCallWriter(stream, 5, 6, "GetValue")) { @@ -1693,7 +1691,6 @@ private void MethodCallRoundtripSingleton(T value) where T : class using (var stream = new MemoryStream()) { serializer.RegisterType(); - Save(); using (var writer = serializer.CreateMethodCallWriter(stream, 5, 6, "GetValue")) { diff --git a/SharpRemote.Test/CodeGeneration/Serialization/Binary/BinarySerializerAcceptanceTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/Binary/BinarySerializerAcceptanceTest.cs index 6726df2..1e71bb7 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/Binary/BinarySerializerAcceptanceTest.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/Binary/BinarySerializerAcceptanceTest.cs @@ -21,7 +21,7 @@ public sealed class BinarySerializerAcceptanceTest public void Setup() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); string moduleName = assemblyName.Name + ".dll"; _module = _assembly.DefineDynamicModule(moduleName); } @@ -31,20 +31,6 @@ protected override ISerializer2 Create() return new BinarySerializer2(_module); } - protected override void Save() - { - var fname = "SharpRemote.GeneratedCode.Serializer.dll"; - try - { - _assembly.Save(fname); - TestContext.Out.WriteLine("Assembly written to: {0}", Path.Combine(Directory.GetCurrentDirectory(), fname)); - } - catch (Exception e) - { - TestContext.Out.WriteLine("Couldn't write assembly: {0}", e); - } - } - public static IEnumerable SupportedVersions => new[] { ProtocolVersion.None, diff --git a/SharpRemote.Test/CodeGeneration/Serialization/FrameworkTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/FrameworkTest.cs index 59590e7..d72dc77 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/FrameworkTest.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/FrameworkTest.cs @@ -14,8 +14,10 @@ public partial class SerializationTest [Test] public void TestAppDomainManagerInitializationOptions() { +#if !NET6_0 _serializer.ShouldRoundtrip(AppDomainManagerInitializationOptions.None); _serializer.ShouldRoundtrip(AppDomainManagerInitializationOptions.RegisterWithHost); +#endif } [Test] @@ -96,8 +98,10 @@ public void TestConsoleSpecialKey() [Test] public void TestContextForm() { +#if !NET6_0 _serializer.ShouldRoundtrip(ActivationContext.ContextForm.Loose); _serializer.ShouldRoundtrip(ActivationContext.ContextForm.StoreBounded); +#endif } [Test] diff --git a/SharpRemote.Test/CodeGeneration/Serialization/Json/JsonSerializerAcceptanceTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/Json/JsonSerializerAcceptanceTest.cs deleted file mode 100644 index 60054f6..0000000 --- a/SharpRemote.Test/CodeGeneration/Serialization/Json/JsonSerializerAcceptanceTest.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.IO; -using NUnit.Framework; - -namespace SharpRemote.Test.CodeGeneration.Serialization.Json -{ - [TestFixture] - public sealed class JsonSerializerAcceptanceTest - : AbstractSerializerAcceptanceTest - { - protected override ISerializer2 Create() - { - return new JsonSerializer(); - } - - protected override string Format(MemoryStream stream) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/SharpRemote.Test/CodeGeneration/Serialization/SerializationTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/SerializationTest.cs index 4eb5a16..185662b 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/SerializationTest.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/SerializationTest.cs @@ -24,18 +24,12 @@ public sealed partial class SerializationTest public void TestFixtureSetUp() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); _moduleName = assemblyName.Name + ".dll"; ModuleBuilder module = _assembly.DefineDynamicModule(_moduleName); _serializer = new BinarySerializer(module); } - - [OneTimeTearDown] - public void TestFixtureTearDown() - { - _assembly.Save(_moduleName); - } - + public static IEnumerable LevelValues => new[] { Level.Error, Level.Alert, Level.All, Level.Critical, Level.Debug, @@ -441,13 +435,13 @@ public void TestClassWithDeserializationCallback() var actualValue = _serializer.Roundtrip(value); const string reason = "because those two callbacks should've been invoked in that order"; - value.Callbacks.Should().Equal(new object[] + value.Callbacks.Should().Equal(new [] { "BeforeSerialization", "AfterSerialization" }, reason); - actualValue.Callbacks.Should().Equal(new object[] + actualValue.Callbacks.Should().Equal(new [] { "BeforeDeserialization", "AfterDeserialization" diff --git a/SharpRemote.Test/CodeGeneration/Serialization/SerializerExtensions.cs b/SharpRemote.Test/CodeGeneration/Serialization/SerializerExtensions.cs index 328cbb2..f13f982 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/SerializerExtensions.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/SerializerExtensions.cs @@ -24,7 +24,7 @@ public static T ShouldRoundtripEnumeration(this ISerializer serializer, T val var reader = new BinaryReader(stream, Encoding.UTF8); var actualValue = (T) serializer.ReadObject(reader, null); - actualValue.Should().Equal(value, "because serialization should preserve the order of elements in the enumeration"); + actualValue.Should().BeEquivalentTo(value, "because serialization should preserve the order of elements in the enumeration"); if (value != null) { actualValue.Should().NotBeSameAs(value, "because serialization should've created a deep copy"); diff --git a/SharpRemote.Test/CodeGeneration/Serialization/Xml/XmlSerializerAcceptanceTest.cs b/SharpRemote.Test/CodeGeneration/Serialization/Xml/XmlSerializerAcceptanceTest.cs index 758d95d..a222758 100644 --- a/SharpRemote.Test/CodeGeneration/Serialization/Xml/XmlSerializerAcceptanceTest.cs +++ b/SharpRemote.Test/CodeGeneration/Serialization/Xml/XmlSerializerAcceptanceTest.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Text; @@ -18,7 +17,7 @@ public sealed class XmlSerializerAcceptanceTest public void Setup() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); - _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); + _assembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); string moduleName = assemblyName.Name + ".dll"; _module = _assembly.DefineDynamicModule(moduleName); } @@ -28,20 +27,6 @@ protected override ISerializer2 Create() return new XmlSerializer(_module); } - protected override void Save() - { - //var fname = "SharpRemote.GeneratedCode.Serializer.dll"; - //try - //{ - // _assembly.Save(fname); - // TestContext.Out.WriteLine("Assembly written to: {0}", Path.Combine(Directory.GetCurrentDirectory(), fname)); - //} - //catch (Exception e) - //{ - // TestContext.Out.WriteLine("Couldn't write assembly: {0}", e); - //} - } - protected override string Format(MemoryStream stream) { using (var reader = new StreamReader(stream, Encoding.Default, detectEncodingFromByteOrderMarks: true, diff --git a/SharpRemote.Test/Exceptions/AuthenticationExceptionTest.cs b/SharpRemote.Test/Exceptions/AuthenticationExceptionTest.cs index ad8f7bd..a896ce6 100644 --- a/SharpRemote.Test/Exceptions/AuthenticationExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/AuthenticationExceptionTest.cs @@ -29,7 +29,11 @@ public void TestRoundtrip() var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); actualException.InnerException.Should().BeOfType(); +#if NET6_0 + actualException.InnerException.Message.Should().Be("Somebody screwed up (Parameter 'foobar')"); +#else actualException.InnerException.Message.Should().Be("Somebody screwed up\r\nParameter name: foobar"); +#endif } } } \ No newline at end of file diff --git a/SharpRemote.Test/Exceptions/AuthenticationRequiredExceptionTest.cs b/SharpRemote.Test/Exceptions/AuthenticationRequiredExceptionTest.cs index fd10b7e..d05bbbc 100644 --- a/SharpRemote.Test/Exceptions/AuthenticationRequiredExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/AuthenticationRequiredExceptionTest.cs @@ -29,7 +29,11 @@ public void TestRoundtrip() var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); actualException.InnerException.Should().BeOfType(); +#if NET6_0 + actualException.InnerException.Message.Should().Be("Somebody screwed up (Parameter 'foobar')"); +#else actualException.InnerException.Message.Should().Be("Somebody screwed up\r\nParameter name: foobar"); +#endif } } } \ No newline at end of file diff --git a/SharpRemote.Test/Exceptions/ConnectionLostExceptionTest.cs b/SharpRemote.Test/Exceptions/ConnectionLostExceptionTest.cs index f96488f..ecbe207 100644 --- a/SharpRemote.Test/Exceptions/ConnectionLostExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/ConnectionLostExceptionTest.cs @@ -1,5 +1,4 @@ -using System.Net; -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using SharpRemote.Test.Extensions; @@ -15,8 +14,6 @@ public void TestConstruction1() var exception = new ConnectionLostException(); exception.Message.Should().Be("The connection to the remote endpoint has been lost"); exception.EndPointName.Should().BeNull("because none has been specified in the ctor"); - exception.LocalEndPoint.Should().BeNull("because none has been specified in the ctor"); - exception.RemoteEndPoint.Should().BeNull("because none has been specified in the ctor"); exception.InnerException.Should().BeNull("because none has been specified in the ctor"); } @@ -26,8 +23,6 @@ public void TestConstruction2() var exception = new ConnectionLostException("My fancy endpoint"); exception.Message.Should().Be("The connection to the remote endpoint has been lost"); exception.EndPointName.Should().Be("My fancy endpoint"); - exception.LocalEndPoint.Should().BeNull("because none has been specified in the ctor"); - exception.RemoteEndPoint.Should().BeNull("because none has been specified in the ctor"); exception.InnerException.Should().BeNull("because none has been specified in the ctor"); } @@ -39,8 +34,6 @@ public void TestRoundtrip1() var actualException = exception.Roundtrip(); actualException.Message.Should().Be("The connection to the remote endpoint has been lost"); actualException.EndPointName.Should().BeNull(); - actualException.LocalEndPoint.Should().BeNull(); - actualException.RemoteEndPoint.Should().BeNull(); } [Test] @@ -51,22 +44,6 @@ public void TestRoundtrip2() var actualException = exception.Roundtrip(); actualException.Message.Should().Be("The connection to the remote endpoint has been lost"); actualException.EndPointName.Should().Be("My fancy endpoint"); - actualException.LocalEndPoint.Should().BeNull(); - actualException.RemoteEndPoint.Should().BeNull(); - } - - [Test] - [SetCulture("en-US")] - public void TestRoundtrip3() - { - var exception = new ConnectionLostException("My fancy endpoint", - new IPEndPoint(IPAddress.Parse("8.8.8.8"), 21), - new IPEndPoint(IPAddress.Parse("2.81.90.1"), 23)); - var actualException = exception.Roundtrip(); - actualException.Message.Should().Be("The connection to the remote endpoint has been lost"); - actualException.EndPointName.Should().Be("My fancy endpoint"); - actualException.LocalEndPoint.Should().Be(new IPEndPoint(IPAddress.Parse("8.8.8.8"), 21)); - actualException.RemoteEndPoint.Should().Be(new IPEndPoint(IPAddress.Parse("2.81.90.1"), 23)); } } -} +} \ No newline at end of file diff --git a/SharpRemote.Test/Exceptions/RemoteEndpointAlreadyConnectedExceptionTest.cs b/SharpRemote.Test/Exceptions/RemoteEndpointAlreadyConnectedExceptionTest.cs index 5a7e98d..079478a 100644 --- a/SharpRemote.Test/Exceptions/RemoteEndpointAlreadyConnectedExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/RemoteEndpointAlreadyConnectedExceptionTest.cs @@ -15,9 +15,9 @@ public void TestConstruction() { var endPoint = new IPEndPoint(IPAddress.Parse("192.21.32.42"), 54321); var innerException = new ArgumentException("dawdwdw"); - var exception = new RemoteEndpointAlreadyConnectedException("foobar", endPoint, innerException); + var exception = new RemoteEndpointAlreadyConnectedException("foobar", endPoint.ToString(), innerException); exception.Message.Should().Be("foobar"); - exception.BlockingEndPoint.Should().BeSameAs(endPoint); + exception.BlockingEndPointName.Should().Be(endPoint.ToString()); exception.InnerException.Should().BeSameAs(innerException); } @@ -27,10 +27,10 @@ public void TestSerializationRoundtrip() var endPoint = new IPEndPoint(IPAddress.Parse("192.21.32.42"), 54321); var innerException = new ArgumentException("dawdwdw"); var message = "Some error message"; - var exception = new RemoteEndpointAlreadyConnectedException(message, endPoint, innerException); + var exception = new RemoteEndpointAlreadyConnectedException(message, endPoint.ToString(), innerException); var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); - actualException.BlockingEndPoint.Should().Be(endPoint); + actualException.BlockingEndPointName.Should().Be(endPoint.ToString()); actualException.InnerException.Should().BeOfType(); actualException.InnerException.Message.Should().Be("dawdwdw"); } diff --git a/SharpRemote.Test/Exceptions/SerializationExceptionTest.cs b/SharpRemote.Test/Exceptions/SerializationExceptionTest.cs index b0085b5..d5ba432 100644 --- a/SharpRemote.Test/Exceptions/SerializationExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/SerializationExceptionTest.cs @@ -29,7 +29,11 @@ public void TestRoundtrip() var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); actualException.InnerException.Should().BeOfType(); +#if NET6_0 + actualException.InnerException.Message.Should().Be("Somebody screwed up (Parameter 'foobar')"); +#else actualException.InnerException.Message.Should().Be("Somebody screwed up\r\nParameter name: foobar"); +#endif } } } diff --git a/SharpRemote.Test/Exceptions/SharpRemoteExceptionTest.cs b/SharpRemote.Test/Exceptions/SharpRemoteExceptionTest.cs index bf9d05c..efcee42 100644 --- a/SharpRemote.Test/Exceptions/SharpRemoteExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/SharpRemoteExceptionTest.cs @@ -29,7 +29,11 @@ public void TestRoundtrip() var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); actualException.InnerException.Should().BeOfType(); +#if NET6_0 + actualException.InnerException.Message.Should().Be("Somebody screwed up (Parameter 'foobar')"); +#else actualException.InnerException.Message.Should().Be("Somebody screwed up\r\nParameter name: foobar"); +#endif } } } \ No newline at end of file diff --git a/SharpRemote.Test/Exceptions/TypeMismatchExceptionTest.cs b/SharpRemote.Test/Exceptions/TypeMismatchExceptionTest.cs index 70bbce3..5957408 100644 --- a/SharpRemote.Test/Exceptions/TypeMismatchExceptionTest.cs +++ b/SharpRemote.Test/Exceptions/TypeMismatchExceptionTest.cs @@ -29,7 +29,11 @@ public void TestRoundtrip() var actualException = exception.Roundtrip(); actualException.Message.Should().Be(message); actualException.InnerException.Should().BeOfType(); +#if NET6_0 + actualException.InnerException.Message.Should().Be("Somebody screwed up (Parameter 'foobar')"); +#else actualException.InnerException.Message.Should().Be("Somebody screwed up\r\nParameter name: foobar"); +#endif } } } diff --git a/SharpRemote.Test/Remoting/AbstractAcceptanceTest.cs b/SharpRemote.Test/Remoting/AbstractAcceptanceTest.cs index 66bf235..90e66e1 100644 --- a/SharpRemote.Test/Remoting/AbstractAcceptanceTest.cs +++ b/SharpRemote.Test/Remoting/AbstractAcceptanceTest.cs @@ -562,7 +562,7 @@ public void TestRaiseEvent2() const int value = 42; new Action(() => subject.Raise(x => x.Foobar += null, value)) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: value"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*value*"); actualValue1.Should().Be(value); actualValue2.Should().NotHaveValue(); @@ -618,7 +618,7 @@ public void TestRaiseEventThrowException1() const int value = 42; new Action(() => subject.Raise(x => x.Foobar += null, value)) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: value"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*value*"); // This line exists to FORCE the GC to NOT collect the subject, which // in turn would unregister the servant from the server, thus making the test @@ -932,7 +932,7 @@ public void TestEventActionStringArray() subject.Raise(x => x.Do += null, new object[] {new[]{"COM11", "COM13"}}); - values.Should().Equal(new object[] + values.Should().Equal(new [] { "COM11", "COM13" @@ -954,7 +954,7 @@ public void TestVoidMethodStringArray() var proxy = _client.CreateProxy(servantId); proxy.Do(new[]{"COM11", "COM13"}); - values.Should().Equal(new object[] + values.Should().Equal(new [] { "COM11", "COM13" diff --git a/SharpRemote.Test/Remoting/AbstractConnectTest.cs b/SharpRemote.Test/Remoting/AbstractConnectTest.cs index 6b02218..0981c10 100644 --- a/SharpRemote.Test/Remoting/AbstractConnectTest.cs +++ b/SharpRemote.Test/Remoting/AbstractConnectTest.cs @@ -83,7 +83,7 @@ public void TestConnect5() { new Action(() => Connect(rep, (EndPoint)null, TimeSpan.FromSeconds(1))) .Should().Throw() - .WithMessage("Value cannot be null.\r\nParameter name: endpoint"); + .WithMessage("Value cannot be null*Parameter*endpoint*"); } } @@ -96,7 +96,7 @@ public void TestConnect6() new Action( () => Connect(rep, EndPoint2, TimeSpan.FromSeconds(0))) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: timeout"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*timeout*"); } } @@ -109,7 +109,7 @@ public void TestConnect7() new Action( () => Connect(rep, EndPoint2, TimeSpan.FromSeconds(-1))) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: timeout"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*timeout*"); } } @@ -250,7 +250,7 @@ public void TestConnect17() { Bind(server); new Action(() => Connect(client, server.LocalEndPoint)) - .Should().Throw(); + .Should().Throw(); server.IsConnected.Should().BeFalse(); client.IsConnected.Should().BeFalse(); } diff --git a/SharpRemote.Test/Remoting/AbstractTryConnectTest.cs b/SharpRemote.Test/Remoting/AbstractTryConnectTest.cs index 4de3d5b..181e9ff 100644 --- a/SharpRemote.Test/Remoting/AbstractTryConnectTest.cs +++ b/SharpRemote.Test/Remoting/AbstractTryConnectTest.cs @@ -165,7 +165,7 @@ public void TestTryConnect5() { new Action(() => TryConnect(rep, (EndPoint)null, TimeSpan.FromSeconds(1))) .Should().Throw() - .WithMessage("Value cannot be null.\r\nParameter name: endpoint"); + .WithMessage("Value cannot be null*Parameter*endpoint*"); } } diff --git a/SharpRemote.Test/Remoting/ExceptionTest.cs b/SharpRemote.Test/Remoting/ExceptionTest.cs index ca4758f..5c4e37f 100644 --- a/SharpRemote.Test/Remoting/ExceptionTest.cs +++ b/SharpRemote.Test/Remoting/ExceptionTest.cs @@ -38,12 +38,17 @@ public void TestPreserveRemoteStacktrace() } catch (Exception e) { +#if NET6_0 + var property = e.GetType().GetProperty("SerializationStackTraceString", BindingFlags.NonPublic | BindingFlags.Instance); +#else var property = e.GetType().GetProperty("RemoteStackTrace", BindingFlags.NonPublic | BindingFlags.Instance); +#endif var remoteStackTrace = (string)property.GetValue(e); remoteStackTrace.Should().NotBeEmpty("because the remote stacktrace of the exception should've been preserved"); var stacktrace = e.StackTrace; - stacktrace.Should().Contain(remoteStackTrace, "because the remote stacktrace should be part of the actual stacktrace to allow for easier debugging of distributed applications (I want to know where it crashed on the server)"); + stacktrace.Should().Contain(remoteStackTrace, + "because the remote stacktrace should be part of the actual stacktrace to allow for easier debugging of distributed applications (I want to know where it crashed on the server)"); } } } diff --git a/SharpRemote.Test/Remoting/Sockets/TryConnectTest.cs b/SharpRemote.Test/Remoting/Sockets/TryConnectTest.cs index cad4635..65db7f7 100644 --- a/SharpRemote.Test/Remoting/Sockets/TryConnectTest.cs +++ b/SharpRemote.Test/Remoting/Sockets/TryConnectTest.cs @@ -135,7 +135,7 @@ public void TestTryConnect6() new Action( () => TryConnect(rep, new IPEndPoint(IPAddress.Loopback, port: 12345), TimeSpan.FromSeconds(value: 0))) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: timeout"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*timeout*"); } } @@ -148,7 +148,7 @@ public void TestTryConnect7() new Action( () => TryConnect(rep, new IPEndPoint(IPAddress.Loopback, port: 12345), TimeSpan.FromSeconds(value: -1))) .Should().Throw() - .WithMessage("Specified argument was out of the range of valid values.\r\nParameter name: timeout"); + .WithMessage("Specified argument was out of the range of valid values*Parameter*timeout*"); } } } diff --git a/SharpRemote.Test/SharpRemote.Test.csproj b/SharpRemote.Test/SharpRemote.Test.csproj index 3f09765..5b745c6 100644 --- a/SharpRemote.Test/SharpRemote.Test.csproj +++ b/SharpRemote.Test/SharpRemote.Test.csproj @@ -1,396 +1,24 @@ - - - - - - Debug - AnyCPU - {377C04C5-EE8C-4159-BDDC-37F1A8372705} - Library - Properties - SharpRemote.Test - SharpRemote.Test - v4.5 - 512 - - - - - - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - true - true - - - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - true - true - - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - ..\packages\FluentAssertions.5.10.3\lib\net45\FluentAssertions.dll - - - ..\packages\FluentAssertions.Extensions.1.0.18\lib\net45\FluentAssertions.Extensions.dll - - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - ..\packages\Moq.4.16.1\lib\net45\Moq.dll - - - ..\packages\NUnit.3.13.2\lib\net45\nunit.framework.dll - - - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - - - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll - - - ..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - - - - - {21218e92-3815-4e5e-9761-c3fb0709f532} - SharpRemote.Host - - - {A358345A-44E1-4767-A20C-A97DE4BAF52C} - SharpRemote.WebApi - - - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - SharpRemote - - - - - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + net48;net6.0 + ..\bin + false + true - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpRemote.Test/TypeModel/TypeModelTest.cs b/SharpRemote.Test/TypeModel/TypeModelTest.cs index a1a206a..086a027 100644 --- a/SharpRemote.Test/TypeModel/TypeModelTest.cs +++ b/SharpRemote.Test/TypeModel/TypeModelTest.cs @@ -201,7 +201,7 @@ public void TestAddObject() description.AssemblyQualifiedName.Should().Be(typeof(object).AssemblyQualifiedName); model.Types.Should().HaveCount(1); - model.Types.Should().Equal(new[] {description}); + model.Types.Should().BeEquivalentTo(new[] {description}); } [Test] @@ -515,12 +515,12 @@ public void TestFieldStruct() field3.FieldType.IsBuiltIn.Should().BeTrue(); ((FieldDescription)field3).FieldTypeId.Should().Be(model.GetId()); - model.Types.Should().Contain(new object[] + model.Types.Should().Contain(new[] { - type, //< FieldStruct - field1.FieldType, //< double - field2.FieldType, //< int - field3.FieldType //< string + (TypeDescription)type, //< FieldStruct + (TypeDescription)field1.FieldType, //< double + (TypeDescription)field2.FieldType, //< int + (TypeDescription)field3.FieldType //< string }); } diff --git a/SharpRemote.Test/WeakKeyDictionaryTest.cs b/SharpRemote.Test/WeakKeyDictionaryTest.cs index 0ee721e..cfceca5 100644 --- a/SharpRemote.Test/WeakKeyDictionaryTest.cs +++ b/SharpRemote.Test/WeakKeyDictionaryTest.cs @@ -84,6 +84,21 @@ private static void EnsureIntegrity(WeakKeyDictionary(); + dictionary.Add("Foobar", 42); + dictionary.Count.Should().Be(1); + dictionary.ContainsKey("Foobar").Should().BeTrue(); + dictionary.Version.Should().Be(1); + + dictionary.Dispose(); + + EnsureIntegrity(dictionary); + } + [Test] [Description("Verifies that adding one key-value pair works")] public void TestAdd1() @@ -282,7 +297,7 @@ public void TestAdd9() var dictionary = new WeakKeyDictionary(); new Action(() => dictionary.Add(null, "foo")) .Should().Throw() - .WithMessage("Value cannot be null.\r\nParameter name: key"); + .And.ParamName.Should().Be("key"); } [Test] diff --git a/SharpRemote.Test/packages.config b/SharpRemote.Test/packages.config deleted file mode 100644 index 45a37dc..0000000 --- a/SharpRemote.Test/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpRemote.Test/WebApi/Attributes/RouteAttributeTest.cs b/SharpRemote.WebApi.Test/Attributes/RouteAttributeTest.cs similarity index 84% rename from SharpRemote.Test/WebApi/Attributes/RouteAttributeTest.cs rename to SharpRemote.WebApi.Test/Attributes/RouteAttributeTest.cs index b0e4c4f..94cf3b1 100644 --- a/SharpRemote.Test/WebApi/Attributes/RouteAttributeTest.cs +++ b/SharpRemote.WebApi.Test/Attributes/RouteAttributeTest.cs @@ -1,8 +1,7 @@ using FluentAssertions; using NUnit.Framework; -using SharpRemote.WebApi; -namespace SharpRemote.Test.WebApi.Attributes +namespace SharpRemote.WebApi.Test.Attributes { [TestFixture] public sealed class RouteAttributeTest diff --git a/SharpRemote.Test/WebApi/Game.cs b/SharpRemote.WebApi.Test/Game.cs similarity index 82% rename from SharpRemote.Test/WebApi/Game.cs rename to SharpRemote.WebApi.Test/Game.cs index bb3f658..03a0c37 100644 --- a/SharpRemote.Test/WebApi/Game.cs +++ b/SharpRemote.WebApi.Test/Game.cs @@ -1,4 +1,4 @@ -namespace SharpRemote.Test.WebApi +namespace SharpRemote.WebApi.Test { public sealed class Game { diff --git a/SharpRemote.Test/WebApi/HttpClientExtensions.cs b/SharpRemote.WebApi.Test/HttpClientExtensions.cs similarity index 87% rename from SharpRemote.Test/WebApi/HttpClientExtensions.cs rename to SharpRemote.WebApi.Test/HttpClientExtensions.cs index 916914b..bfdb660 100644 --- a/SharpRemote.Test/WebApi/HttpClientExtensions.cs +++ b/SharpRemote.WebApi.Test/HttpClientExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Net.Http; -namespace SharpRemote.Test.WebApi +namespace SharpRemote.WebApi.Test { public static class HttpClientExtensions { diff --git a/SharpRemote.Test/WebApi/HttpResponseMessageExtensions.cs b/SharpRemote.WebApi.Test/HttpResponseMessageExtensions.cs similarity index 86% rename from SharpRemote.Test/WebApi/HttpResponseMessageExtensions.cs rename to SharpRemote.WebApi.Test/HttpResponseMessageExtensions.cs index 3d66b3c..62c81e7 100644 --- a/SharpRemote.Test/WebApi/HttpResponseMessageExtensions.cs +++ b/SharpRemote.WebApi.Test/HttpResponseMessageExtensions.cs @@ -1,6 +1,6 @@ using System.Net.Http; -namespace SharpRemote.Test.WebApi +namespace SharpRemote.WebApi.Test { public static class HttpResponseMessageExtensions { diff --git a/SharpRemote.Test/Types/Interfaces/Web/IGameController.cs b/SharpRemote.WebApi.Test/IGameController.cs similarity index 60% rename from SharpRemote.Test/Types/Interfaces/Web/IGameController.cs rename to SharpRemote.WebApi.Test/IGameController.cs index 9ce8b01..c5cc225 100644 --- a/SharpRemote.Test/Types/Interfaces/Web/IGameController.cs +++ b/SharpRemote.WebApi.Test/IGameController.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; -using SharpRemote.Test.WebApi; -using SharpRemote.WebApi; -namespace SharpRemote.Test.Types.Interfaces.Web +namespace SharpRemote.WebApi.Test { public interface IGameController { diff --git a/SharpRemote.Test/Types/Interfaces/Web/IGetString.cs b/SharpRemote.WebApi.Test/IGetString.cs similarity index 64% rename from SharpRemote.Test/Types/Interfaces/Web/IGetString.cs rename to SharpRemote.WebApi.Test/IGetString.cs index 4352132..9e2320a 100644 --- a/SharpRemote.Test/Types/Interfaces/Web/IGetString.cs +++ b/SharpRemote.WebApi.Test/IGetString.cs @@ -1,6 +1,4 @@ -using SharpRemote.WebApi; - -namespace SharpRemote.Test.Types.Interfaces.Web +namespace SharpRemote.WebApi.Test { public interface IGetString { diff --git a/SharpRemote.Test/Types/Interfaces/Web/IGetStringList.cs b/SharpRemote.WebApi.Test/IGetStringList.cs similarity index 68% rename from SharpRemote.Test/Types/Interfaces/Web/IGetStringList.cs rename to SharpRemote.WebApi.Test/IGetStringList.cs index d5ff86d..03f7361 100644 --- a/SharpRemote.Test/Types/Interfaces/Web/IGetStringList.cs +++ b/SharpRemote.WebApi.Test/IGetStringList.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; -using SharpRemote.WebApi; -namespace SharpRemote.Test.Types.Interfaces.Web +namespace SharpRemote.WebApi.Test { public interface IGetStringList { diff --git a/SharpRemote.Test/Types/Interfaces/Web/ITwoIdenticalRoutes.cs b/SharpRemote.WebApi.Test/ITwoIdenticalRoutes.cs similarity index 57% rename from SharpRemote.Test/Types/Interfaces/Web/ITwoIdenticalRoutes.cs rename to SharpRemote.WebApi.Test/ITwoIdenticalRoutes.cs index c8e93c7..7b4e9bc 100644 --- a/SharpRemote.Test/Types/Interfaces/Web/ITwoIdenticalRoutes.cs +++ b/SharpRemote.WebApi.Test/ITwoIdenticalRoutes.cs @@ -1,6 +1,4 @@ -using SharpRemote.WebApi; - -namespace SharpRemote.Test.Types.Interfaces.Web +namespace SharpRemote.WebApi.Test { public interface ITwoIdenticalRoutes { diff --git a/Samples/SampleLibrary/Properties/AssemblyInfo.cs b/SharpRemote.WebApi.Test/Properties/AssemblyInfo.cs similarity index 85% rename from Samples/SampleLibrary/Properties/AssemblyInfo.cs rename to SharpRemote.WebApi.Test/Properties/AssemblyInfo.cs index 8b37cc8..94afd40 100644 --- a/Samples/SampleLibrary/Properties/AssemblyInfo.cs +++ b/SharpRemote.WebApi.Test/Properties/AssemblyInfo.cs @@ -5,11 +5,12 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("SampleLibrary")] + +[assembly: AssemblyTitle("SharpRemote.WebApi.Test")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SampleLibrary")] +[assembly: AssemblyProduct("SharpRemote.WebApi.Test")] [assembly: AssemblyCopyright("Copyright © Kittyfisto 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -17,10 +18,12 @@ // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. + [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("20534a2d-e012-42af-a0e1-0b131ac9dc9b")] + +[assembly: Guid("a0397cd4-7382-424c-9c33-e00821d9d3f1")] // Version information for an assembly consists of the following four values: // @@ -32,5 +35,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] + [assembly: AssemblyVersion("0.6.0.0")] -[assembly: AssemblyFileVersion("0.6.0.0")] +[assembly: AssemblyFileVersion("0.6.0.0")] \ No newline at end of file diff --git a/SharpRemote.Test/WebApi/Requests/RequestHandlerTest.cs b/SharpRemote.WebApi.Test/Requests/RequestHandlerTest.cs similarity index 96% rename from SharpRemote.Test/WebApi/Requests/RequestHandlerTest.cs rename to SharpRemote.WebApi.Test/Requests/RequestHandlerTest.cs index 7f0a2d6..7e7d24a 100644 --- a/SharpRemote.Test/WebApi/Requests/RequestHandlerTest.cs +++ b/SharpRemote.WebApi.Test/Requests/RequestHandlerTest.cs @@ -3,12 +3,10 @@ using FluentAssertions; using Moq; using NUnit.Framework; -using SharpRemote.Test.Types.Interfaces.Web; -using SharpRemote.WebApi; using SharpRemote.WebApi.Requests; using SharpRemote.WebApi.Resources; -namespace SharpRemote.Test.WebApi.Requests +namespace SharpRemote.WebApi.Test.Requests { [TestFixture] public sealed class RequestHandlerTest diff --git a/SharpRemote.Test/WebApi/Routes/RouteTest.cs b/SharpRemote.WebApi.Test/Routes/RouteTest.cs similarity index 99% rename from SharpRemote.Test/WebApi/Routes/RouteTest.cs rename to SharpRemote.WebApi.Test/Routes/RouteTest.cs index d15fe25..8b97bf2 100644 --- a/SharpRemote.Test/WebApi/Routes/RouteTest.cs +++ b/SharpRemote.WebApi.Test/Routes/RouteTest.cs @@ -5,7 +5,7 @@ using SharpRemote.WebApi; using SharpRemote.WebApi.Routes; -namespace SharpRemote.Test.WebApi.Routes +namespace SharpRemote.WebApi.Test.Routes { [TestFixture] public sealed class RouteTest diff --git a/SharpRemote.Test/WebApi/Routes/RouteTokenTest.cs b/SharpRemote.WebApi.Test/Routes/RouteTokenTest.cs similarity index 98% rename from SharpRemote.Test/WebApi/Routes/RouteTokenTest.cs rename to SharpRemote.WebApi.Test/Routes/RouteTokenTest.cs index 005ff59..6e4125e 100644 --- a/SharpRemote.Test/WebApi/Routes/RouteTokenTest.cs +++ b/SharpRemote.WebApi.Test/Routes/RouteTokenTest.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using SharpRemote.WebApi.Routes; -namespace SharpRemote.Test.WebApi.Routes +namespace SharpRemote.WebApi.Test.Routes { [TestFixture] public sealed class RouteTokenTest diff --git a/SharpRemote.WebApi.Test/SharpRemote.WebApi.Test.csproj b/SharpRemote.WebApi.Test/SharpRemote.WebApi.Test.csproj new file mode 100644 index 0000000..5214e87 --- /dev/null +++ b/SharpRemote.WebApi.Test/SharpRemote.WebApi.Test.csproj @@ -0,0 +1,22 @@ + + + net48 + ..\bin + false + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpRemote.Test/WebApi/WebApiControllerTest.cs b/SharpRemote.WebApi.Test/WebApiControllerTest.cs similarity index 89% rename from SharpRemote.Test/WebApi/WebApiControllerTest.cs rename to SharpRemote.WebApi.Test/WebApiControllerTest.cs index 10a8830..8aa742c 100644 --- a/SharpRemote.Test/WebApi/WebApiControllerTest.cs +++ b/SharpRemote.WebApi.Test/WebApiControllerTest.cs @@ -4,19 +4,16 @@ using FluentAssertions; using Moq; using NUnit.Framework; -using SharpRemote.Extensions; -using SharpRemote.Test.Types.Interfaces.Web; -using SharpRemote.WebApi; using SharpRemote.WebApi.HttpListener; -namespace SharpRemote.Test.WebApi +namespace SharpRemote.WebApi.Test { [TestFixture] public sealed class WebApiControllerTest { private IPEndPoint _localEndPoint; private HttpClient _client; - private HttpListener _listener; + private System.Net.HttpListener _listener; private string _apiUrl; private WebApiController _server; private SystemNetHttpListener _container; @@ -24,7 +21,7 @@ public sealed class WebApiControllerTest [SetUp] public void Setup() { - _listener = new HttpListener(); + _listener = new System.Net.HttpListener(); _localEndPoint = new IPEndPoint(IPAddress.Loopback, 8080); _apiUrl = string.Format("http://{0}/sharpremote/api/test/", _localEndPoint); _listener.Prefixes.Add(_apiUrl); @@ -41,7 +38,7 @@ public void TearDown() _container?.Dispose(); _server?.Dispose(); _client?.Dispose(); - _listener?.TryDispose(); + ((IDisposable)_listener)?.Dispose(); } private Uri CreateUri(string suffix) diff --git a/SharpRemote.WebApi/Properties/AssemblyInfo.cs b/SharpRemote.WebApi/Properties/AssemblyInfo.cs index 213df7c..f38216a 100644 --- a/SharpRemote.WebApi/Properties/AssemblyInfo.cs +++ b/SharpRemote.WebApi/Properties/AssemblyInfo.cs @@ -35,12 +35,4 @@ [assembly: AssemblyVersion("0.6.0.0")] [assembly: AssemblyFileVersion("0.6.0.0")] -#if DEBUG -[assembly: InternalsVisibleTo("SharpRemote.Test")] -#else -[assembly: InternalsVisibleTo("SharpRemote.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001006d873a2f2f5d54" + - "280b91e8a2b6997fbe287f0631db99675716fbd9ded5ae79276ec77851fbe7be4e975bae1bc1d6" + - "dcc76d4e00ab7dbba236f2c2e842310cc6b842ae0785afd969bf0b2fc79b5a902cf0e7278dbf33" + - "00e9158b2693d209dfda4670b3ef8f660b7bc7be6028bcef1665f4aaaa8cc6851d36968210ea77" + - "1db7ebdb")] -#endif \ No newline at end of file +[assembly: InternalsVisibleTo("SharpRemote.WebApi.Test")] \ No newline at end of file diff --git a/SharpRemote.WebApi/Routes/RouteToken.cs b/SharpRemote.WebApi/Routes/RouteToken.cs index bfd0ed9..ecb4456 100644 --- a/SharpRemote.WebApi/Routes/RouteToken.cs +++ b/SharpRemote.WebApi/Routes/RouteToken.cs @@ -5,7 +5,7 @@ namespace SharpRemote.WebApi.Routes { - internal struct RouteToken : IEquatable + internal readonly struct RouteToken : IEquatable { public readonly TokenType Type; public readonly string Pattern; diff --git a/SharpRemote.WebApi/SharpRemote.WebApi.csproj b/SharpRemote.WebApi/SharpRemote.WebApi.csproj index 403a70b..3fbcbce 100644 --- a/SharpRemote.WebApi/SharpRemote.WebApi.csproj +++ b/SharpRemote.WebApi/SharpRemote.WebApi.csproj @@ -1,89 +1,13 @@ - - - + - Debug - AnyCPU - {A358345A-44E1-4767-A20C-A97DE4BAF52C} - Library - Properties - SharpRemote.WebApi - SharpRemote.WebApi - v4.5 - 512 - - - - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - ..\bin\win\SharpRemote.WebApi.XML - true - - - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - ..\bin\win\SharpRemote.WebApi.XML - true + net48 + ..\bin + false - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SharpRemote.WebApi/packages.config b/SharpRemote.WebApi/packages.config deleted file mode 100644 index 6419ef8..0000000 --- a/SharpRemote.WebApi/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/SharpRemote.sln b/SharpRemote.sln index 4ec8654..94aa76c 100644 --- a/SharpRemote.sln +++ b/SharpRemote.sln @@ -18,24 +18,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{FEBC EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{E624D4D5-6EF9-4DCE-B5FC-C7DB6F387760}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C54CC6BB-A650-475B-A07B-94FCA8BE71A3}" - ProjectSection(SolutionItems) = preProject - .nuget\packages.config = .nuget\packages.config - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote.Host", "SharpRemote.Host\SharpRemote.Host.csproj", "{21218E92-3815-4E5E-9761-C3FB0709F532}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleLibrary", "Samples\SampleLibrary\SampleLibrary.csproj", "{21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windows", "Windows", "{E0FFF03D-34B3-406E-9456-501E0C9D8E1C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleBrowser", "Samples\SampleBrowser\SampleBrowser.csproj", "{4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8CE88288-47DE-4A6D-9770-A49E69A48E54}" - ProjectSection(SolutionItems) = preProject - .nuget\packages.config = .nuget\packages.config - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{9C8FF3F3-C560-4390-A113-3A5220F02E15}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote.Host.FailsStartup", "SharpRemote.Host.FailsStartup\SharpRemote.Host.FailsStartup.csproj", "{C0C2492B-E3E3-49E2-BA97-76CB07C3F473}" @@ -48,9 +36,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote.Bluetooth", "Sh EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote", "SharpRemote\SharpRemote.csproj", "{1B908B3A-2F3B-47B8-B69F-3827B8829586}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote.NETCore", "SharpRemote.NETCore\SharpRemote.NETCore.csproj", "{04D02962-8266-4AF1-8C80-7D5E1F42902F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET Core", ".NET Core", "{E7D09E86-9459-4E27-B1B3-476F123956C1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRemote.WebApi.Test", "SharpRemote.WebApi.Test\SharpRemote.WebApi.Test.csproj", "{E43549CF-7DAF-461E-A2EF-16866526FFF2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -100,22 +86,6 @@ Global {21218E92-3815-4E5E-9761-C3FB0709F532}.Release|Win32.ActiveCfg = Release|Any CPU {21218E92-3815-4E5E-9761-C3FB0709F532}.Release|x64.ActiveCfg = Release|Any CPU {21218E92-3815-4E5E-9761-C3FB0709F532}.Release|x86.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|ARM.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|Win32.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|x64.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Debug|x86.ActiveCfg = Debug|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|Any CPU.Build.0 = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|ARM.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|Win32.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|x64.ActiveCfg = Release|Any CPU - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6}.Release|x86.ActiveCfg = Release|Any CPU {4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -165,7 +135,6 @@ Global {C0C2492B-E3E3-49E2-BA97-76CB07C3F473}.Release|x64.ActiveCfg = Release|Any CPU {C0C2492B-E3E3-49E2-BA97-76CB07C3F473}.Release|x86.ActiveCfg = Release|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|Any CPU.Build.0 = Debug|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|ARM.ActiveCfg = Debug|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU @@ -180,6 +149,7 @@ Global {792694CE-6935-4452-9F3C-319ADAA87A26}.Release|Win32.ActiveCfg = Release|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Release|x64.ActiveCfg = Release|Any CPU {792694CE-6935-4452-9F3C-319ADAA87A26}.Release|x86.ActiveCfg = Release|Any CPU + {792694CE-6935-4452-9F3C-319ADAA87A26}.Debug|Any CPU.Build.0 = Debug|Any CPU {A358345A-44E1-4767-A20C-A97DE4BAF52C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A358345A-44E1-4767-A20C-A97DE4BAF52C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A358345A-44E1-4767-A20C-A97DE4BAF52C}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -252,30 +222,30 @@ Global {1B908B3A-2F3B-47B8-B69F-3827B8829586}.Release|x64.Build.0 = Release|Any CPU {1B908B3A-2F3B-47B8-B69F-3827B8829586}.Release|x86.ActiveCfg = Release|Any CPU {1B908B3A-2F3B-47B8-B69F-3827B8829586}.Release|x86.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|ARM.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|ARM.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Win32.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|Win32.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|x64.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|x64.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|x86.ActiveCfg = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Debug|x86.Build.0 = Debug|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Any CPU.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|ARM.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|ARM.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Win32.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|Win32.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|x64.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|x64.Build.0 = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|x86.ActiveCfg = Release|Any CPU - {04D02962-8266-4AF1-8C80-7D5E1F42902F}.Release|x86.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|ARM.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Win32.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|Win32.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|x64.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|x64.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|x86.ActiveCfg = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Debug|x86.Build.0 = Debug|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Any CPU.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|ARM.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|ARM.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Win32.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|Win32.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|x64.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|x64.Build.0 = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|x86.ActiveCfg = Release|Any CPU + {E43549CF-7DAF-461E-A2EF-16866526FFF2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -284,9 +254,7 @@ Global {377C04C5-EE8C-4159-BDDC-37F1A8372705} = {E624D4D5-6EF9-4DCE-B5FC-C7DB6F387760} {FEBCB651-C5D8-4374-BF9C-20D6FE6AC60E} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} {E624D4D5-6EF9-4DCE-B5FC-C7DB6F387760} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} - {C54CC6BB-A650-475B-A07B-94FCA8BE71A3} = {4539F890-A585-4651-BE41-6D560801E44C} {21218E92-3815-4E5E-9761-C3FB0709F532} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} - {21331D8D-C95A-44AE-BB90-62F9CA0F1AB6} = {FEBCB651-C5D8-4374-BF9C-20D6FE6AC60E} {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} = {0DFD78EE-EFBE-4F42-8195-87BF371EAFDD} {4C11A5D4-F468-4B6E-BB57-2E1B521DBCB2} = {FEBCB651-C5D8-4374-BF9C-20D6FE6AC60E} {9C8FF3F3-C560-4390-A113-3A5220F02E15} = {FEBCB651-C5D8-4374-BF9C-20D6FE6AC60E} @@ -295,8 +263,7 @@ Global {A358345A-44E1-4767-A20C-A97DE4BAF52C} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} {41F098DA-29DC-48AF-9C6C-2BC6F4F0BE41} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} {1B908B3A-2F3B-47B8-B69F-3827B8829586} = {E0FFF03D-34B3-406E-9456-501E0C9D8E1C} - {04D02962-8266-4AF1-8C80-7D5E1F42902F} = {E7D09E86-9459-4E27-B1B3-476F123956C1} - {E7D09E86-9459-4E27-B1B3-476F123956C1} = {0DFD78EE-EFBE-4F42-8195-87BF371EAFDD} + {E43549CF-7DAF-461E-A2EF-16866526FFF2} = {E624D4D5-6EF9-4DCE-B5FC-C7DB6F387760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5442B4F2-5ED4-4348-ABD6-A94338AA6D46} diff --git a/SharpRemote.sln.DotSettings b/SharpRemote.sln.DotSettings index 330dfae..f9305c2 100644 --- a/SharpRemote.sln.DotSettings +++ b/SharpRemote.sln.DotSettings @@ -58,6 +58,7 @@ LIVE_MONITOR DO_NOTHING LIVE_MONITOR + True True <data><IncludeFilters /><ExcludeFilters /></data> <data /> diff --git a/SharpRemote/CodeGeneration/CodeGenerator.cs b/SharpRemote/CodeGeneration/CodeGenerator.cs index 5809467..6d3657f 100644 --- a/SharpRemote/CodeGeneration/CodeGenerator.cs +++ b/SharpRemote/CodeGeneration/CodeGenerator.cs @@ -63,7 +63,7 @@ public CodeGenerator(ITypeResolver customTypeResolver = null) { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/FaultTolerance/ProxyCreator.cs b/SharpRemote/CodeGeneration/FaultTolerance/ProxyCreator.cs index 892eb75..a2bde1a 100644 --- a/SharpRemote/CodeGeneration/FaultTolerance/ProxyCreator.cs +++ b/SharpRemote/CodeGeneration/FaultTolerance/ProxyCreator.cs @@ -36,7 +36,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.FaultTolerance"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/Remoting/RemotingProxyCreator.cs b/SharpRemote/CodeGeneration/Remoting/RemotingProxyCreator.cs index 3da9174..203085b 100644 --- a/SharpRemote/CodeGeneration/Remoting/RemotingProxyCreator.cs +++ b/SharpRemote/CodeGeneration/Remoting/RemotingProxyCreator.cs @@ -40,7 +40,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Proxies"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/Remoting/ServantCreator.cs b/SharpRemote/CodeGeneration/Remoting/ServantCreator.cs index 61ddff3..39aa291 100644 --- a/SharpRemote/CodeGeneration/Remoting/ServantCreator.cs +++ b/SharpRemote/CodeGeneration/Remoting/ServantCreator.cs @@ -37,7 +37,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Servants"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer.cs b/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer.cs index 03987ac..0f9bcef 100644 --- a/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer.cs +++ b/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer.cs @@ -134,7 +134,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer2.cs b/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer2.cs index f2a3132..afadbe6 100644 --- a/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer2.cs +++ b/SharpRemote/CodeGeneration/Serialization/Binary/BinarySerializer2.cs @@ -92,7 +92,11 @@ public void CreateMethodReader(Stream stream, out IMethodResultReader resultReader, IRemotingEndPoint endPoint = null) { +#if NET6_0 + var reader = new BinaryReader(stream, Encoding.UTF8); +#else var reader = new BinaryReader(stream, Encoding.UTF8, true); +#endif var type = (MessageType2)reader.ReadByte(); if (type == MessageType2.Call) { @@ -550,7 +554,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/Serialization/Binary/Serializers/BuiltInTypeSerializer.cs b/SharpRemote/CodeGeneration/Serialization/Binary/Serializers/BuiltInTypeSerializer.cs index 9a7540a..86ac39d 100644 --- a/SharpRemote/CodeGeneration/Serialization/Binary/Serializers/BuiltInTypeSerializer.cs +++ b/SharpRemote/CodeGeneration/Serialization/Binary/Serializers/BuiltInTypeSerializer.cs @@ -7,7 +7,7 @@ namespace SharpRemote.CodeGeneration.Serialization.Binary.Serializers /// /// Takes care of serializing / deserializing Type values. /// Serialization simply writes the type's assembly qualified name, e.g. "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" - /// and deserialization calls or a user specified method. + /// and deserialization calls or a user specified method. /// internal sealed class BuiltInTypeSerializer : AbstractTypeSerializer diff --git a/SharpRemote/CodeGeneration/Serialization/Xml/XmlSerializer.cs b/SharpRemote/CodeGeneration/Serialization/Xml/XmlSerializer.cs index 7b3a9ec..ace5dbf 100644 --- a/SharpRemote/CodeGeneration/Serialization/Xml/XmlSerializer.cs +++ b/SharpRemote/CodeGeneration/Serialization/Xml/XmlSerializer.cs @@ -904,7 +904,7 @@ private static ModuleBuilder CreateModule() { var assemblyName = new AssemblyName("SharpRemote.GeneratedCode.Serializer"); -#if DOTNETCORE +#if NET6_0 var access = AssemblyBuilderAccess.Run; #else var access = AssemblyBuilderAccess.RunAndSave; diff --git a/SharpRemote/CodeGeneration/TypeLoader.cs b/SharpRemote/CodeGeneration/TypeLoader.cs new file mode 100644 index 0000000..2fd6779 --- /dev/null +++ b/SharpRemote/CodeGeneration/TypeLoader.cs @@ -0,0 +1,43 @@ +#if NET6_0 +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; + +namespace SharpRemote.CodeGeneration +{ + public sealed class TypeLoader + { + private readonly object _resolutionLock = new object(); + + public Type LoadType(string typeName, AssemblyName assemblyName, bool throwOnError) + { + var context = AssemblyLoadContext.Default; + lock (_resolutionLock) + { + var type = (from loadedAssembly in AppDomain.CurrentDomain.GetAssemblies() + let foundType = loadedAssembly.GetType(typeName, false) + where foundType != null + select foundType).FirstOrDefault(); + + if (type != null) + return type; + + context.Resolving += OnContextResolving; + var assembly = context.LoadFromAssemblyName(assemblyName); + context.Resolving -= OnContextResolving; + + type = assembly.GetType(typeName, throwOnError); + return type; + } + } + + private static Assembly OnContextResolving(AssemblyLoadContext context, AssemblyName assemblyName) + { + var expectedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assemblyName.Name + ".dll"); + return context.LoadFromAssemblyPath(expectedPath); + } + } +} +#endif \ No newline at end of file diff --git a/SharpRemote/CodeGeneration/TypeName.cs b/SharpRemote/CodeGeneration/TypeName.cs new file mode 100644 index 0000000..83cc9fb --- /dev/null +++ b/SharpRemote/CodeGeneration/TypeName.cs @@ -0,0 +1,533 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Contracts; +using System.Linq; +using System.Reflection; +using log4net; + +namespace SharpRemote.CodeGeneration +{ + /// + /// Represents a .NET type that may or may not be loaded into the current AppDomain + /// (as opposed to which can ONLY represent types loaded into the current + /// AppDomain). + /// + internal sealed class TypeName + { + #region Fields + + private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Cache to store assembly names for types which were already found + /// + private static readonly Dictionary TypeDictionary = new Dictionary(); + + private readonly TypeName _genericTypeDefinition; + private readonly AssemblyName _assemblyName; + private readonly string _name; + private readonly string _namespace; + private readonly string _fullTypeNameWithNamespace; + private readonly TypeName[] _genericTypeArguments; + private readonly TypeName _declaringType; + + #endregion + + #region Properties + + /// + /// The type-name of this type, ignoring any inner types (only differs from + /// in case this is a generic type. + /// + public TypeName GenericTypeDefinition => _genericTypeDefinition; + + public bool IsGenericTypeDefinition => GenericTypeArguments != null && GenericTypeArguments.Any(x => x == null); + + /// + /// The generic-type arguments, if there are any. + /// Is set null for each argument that is not specified, + /// for example List{} has one generic argument that is not specified, hence + /// the reference will be null. + /// + public TypeName[] GenericTypeArguments => _genericTypeArguments; + + public TypeName DeclaringType => _declaringType; + + /// + /// The amount of generic arguments this type contains. + /// + public int NumGenericArguments => GenericTypeArguments != null ? GenericTypeArguments.Length : 0; + + public bool IsGenericType => NumGenericArguments > 0; + + /// + /// The full typename (e.g. System.List{System.Int}). + /// + public string FullName + { + get + { + if (_assemblyName == null) + return _fullTypeNameWithNamespace; + + return string.Format("{0}, {1}", _fullTypeNameWithNamespace, _assemblyName); + } + } + + public string Name => _name; + + public string Namespace => _namespace; + + /// + /// The full typename (e.g. System.List{System.Int}). + /// + public string FullTypeNameWithNamespace => _fullTypeNameWithNamespace; + + public AssemblyName AssemblyName => _assemblyName; + + public bool IsArray => Name.EndsWith("[]"); + + #endregion + + #region Constructor + + private TypeName(string typeNameWithNamespace, + AssemblyName assemblyName, + TypeName declaringType, + TypeName genericTypeDefinition, + params TypeName[] genericTypeArguments) + { + if (string.IsNullOrWhiteSpace(typeNameWithNamespace)) + throw new ArgumentOutOfRangeException(nameof(typeNameWithNamespace)); + + _fullTypeNameWithNamespace = typeNameWithNamespace; + _genericTypeDefinition = genericTypeDefinition; + _assemblyName = assemblyName; + _genericTypeArguments = genericTypeArguments; + _declaringType = declaringType; + + // ReSharper disable once StringIndexOfIsCultureSpecific.1 + var indexOfGenericType = typeNameWithNamespace.IndexOf("[["); + if (IsGenericType && indexOfGenericType != -1) + { + var typeNameWithNamespaceWithoutGenericType = typeNameWithNamespace.Substring(0, indexOfGenericType); + GetName(typeNameWithNamespaceWithoutGenericType, out _name, out _namespace); + } + else + { + GetName(typeNameWithNamespace, out _name, out _namespace); + } + } + + #endregion + + #region Public Methods + + public static AssemblyName FindAssembly(string typeName) + { + lock (TypeDictionary) + { + if (TypeDictionary.ContainsKey(typeName)) + return TypeDictionary[typeName]; + } + + foreach (var ass in AppDomain.CurrentDomain.GetAssemblies()) + { + try + { + foreach (var t in ass.GetTypes()) + { + if (string.Equals(t.FullName, typeName, StringComparison.InvariantCulture)) + { + lock (TypeDictionary) + { + // We do NOT lock the entire method, therefore + // we cannot assume that the given type hasn't been added before. + TypeDictionary[typeName] = ass.GetName(); + } + + return ass.GetName(); + } + } + } + catch (ReflectionTypeLoadException ex) + { + var buildString = string.Join(", ", ex.LoaderExceptions.Where(x => x != null).Select(x => x.ToString())); + Log.ErrorFormat("exception {0} while searching for type {1}: {2}", ex.Message, typeName, buildString); + } + } + + return null; + } + + public static bool TryParse(string typeName, out TypeName ret) + { + // It's possible that we're not given a fully quallified name + var split = SplitStrongName(typeName); + if (split.Length != 1 && split.Length != 2) + { + ret = null; + return false; + } + + var assembly = split.Length >= 2 ? new AssemblyName(split[1]) : null; + + ret = Create(split[0], assembly); + return true; + } + + + public static TypeName Parse(string typeName) + { + if (!TryParse(typeName, out var ret)) + throw new FormatException(string.Format("'{0}' does not contain a representation of a .NET type-name", typeName)); + + return ret; + } + + /// + /// Tries to create a new object that represents the given full typename. + /// The object contains a description of all generic type arguments, if the typename contains any. + /// + /// + /// + /// + /// + public static bool TryCreate(string fullTypeName, AssemblyName assemblyName, out TypeName typeName) + { + if (!TryParseGenericTypeArguments(fullTypeName, out var genericTypeDefinitionName, out var genericTypeArguments)) + { + typeName = null; + return false; + } + + // In fullTypeName refers to a closed generic type, then we will never find an assembly + // that contains that type (for example there is no assembly that contains the type + // "System.Collections.Generic.List`1[[System.Int]]", but there most certainly is one that + // contains "System.Collections.Generic.List`1". Thus the assembly-lookup needs to be performed + // on the generic-type-definition, not the fullTypeName. + if (assemblyName == null) + { + assemblyName = FindAssembly(genericTypeDefinitionName ?? fullTypeName); + } + + TypeName genericTypeDefinition = null; + if (genericTypeDefinitionName != null) + { + var args = new TypeName[genericTypeArguments.Length]; + genericTypeDefinition = new TypeName(genericTypeDefinitionName, assemblyName, null, null, args); + } + + TypeName declaringType = null; + if (TryParseDeclaringType(fullTypeName, out var declaringTypeName, out _)) + { + declaringType = new TypeName(declaringTypeName, assemblyName, null, null); + } + + typeName = new TypeName(fullTypeName, assemblyName, declaringType, genericTypeDefinition, genericTypeArguments); + return true; + } + + [Pure] + public static TypeName Create(string typeNameWithNamespace, AssemblyName assemblyName) + { + if (!TryCreate(typeNameWithNamespace, assemblyName, out var typeName)) + throw new FormatException(string.Format("'{0}' does not contain a representation of a .NET type-name", typeName)); + + return typeName; + } + + [Pure] + public static TypeName Create(string typeNameWithNamespace, string assemblyName = null) + { + return Create(typeNameWithNamespace, assemblyName != null ? new AssemblyName(assemblyName) : null); + } + + /// + /// Creates a generic type from this generic type definition and the given arguments. + /// + /// + /// + public TypeName MakeGenericType(params TypeName[] genericTypeArguments) + { + Contract.Requires(IsGenericTypeDefinition); + + var fullName = BuildFullName(this, genericTypeArguments); + return new TypeName(fullName, + _assemblyName, + null, + this, + genericTypeArguments); + } + + public override bool Equals(object obj) + { + if (!(obj is TypeName)) + return false; + + return Equals((TypeName)obj); + } + + public override int GetHashCode() + { + return FullName.GetHashCode(); + } + + public override string ToString() + { + return FullName; + } + + #endregion + + #region Protected Methods + + /// + /// Extracts the number of generic type arguments and returns the index of the + /// start of the first generic type argument in the given full typename. + /// + /// + /// + /// + /// + /// + internal static bool TryParseNumberOfGenericTypeArguments(string fullTypename, + out string genericTypeDefinition, + out int indexOfFirstArgument, + out int numberOfGenericTypeArguments) + { + var pos = fullTypename.IndexOf('`'); + if (pos == -1) //< no '? => it's no generic type then + { + indexOfFirstArgument = -1; + numberOfGenericTypeArguments = 0; + genericTypeDefinition = null; + return true; + } + + pos += 1; + var end = fullTypename.IndexOf('[', pos); + if (end == -1) + { + // "System.List`1" is a valid typename, as is + // "System.List`1[[System.Int]]" => if we cannot find a [ then + // we assume that fullTypename is like the first example.... + end = fullTypename.Length; + } + + var num = fullTypename.Substring(pos, end - pos); + if (!int.TryParse(num, out numberOfGenericTypeArguments) || numberOfGenericTypeArguments < 1) + { + indexOfFirstArgument = -1; + numberOfGenericTypeArguments = 0; + genericTypeDefinition = null; + return false; + } + + genericTypeDefinition = fullTypename.Substring(0, end); + indexOfFirstArgument = end + 1; + return true; + } + + /// + /// Extracts the typename of the next generic type argument from the given string. + /// Expects the type argument to start at the given position, e.g. the first character + /// must be '[', otherwise the full typename is assumed to be malformatted. + /// + /// + /// + /// + /// + internal static bool TryExtractGenericTypeArgument(string fullTypename, + ref int start, + out string fullyQualifiedTypename) + { + var bcount = 0; + for (var i = start; i < fullTypename.Length; ++i) + { + var c = fullTypename[i]; + if (c == '[') + { + ++bcount; + } + else if (c == ']') + { + --bcount; + + if (bcount == 0) + { + fullyQualifiedTypename = fullTypename.Substring(start + 1, i - start - 1); + start = i + 1; + return true; + } + } + } + + fullyQualifiedTypename = null; + return false; + } + + #endregion + + #region Private Methods + + private static void GetName(string typeNameWithNamespace, out string name, out string @namespace) + { + var index = typeNameWithNamespace.LastIndexOf('.'); + if (index != -1) + { + @namespace = typeNameWithNamespace.Substring(0, index); + name = typeNameWithNamespace.Substring(index + 1); + } + else + { + @namespace = string.Empty; + name = typeNameWithNamespace; + } + + index = name.LastIndexOf("+"); + if (index != -1) + name = name.Substring(index + 1); + } + + /// + /// Splits the strong name into two parts: One identifying the type itself (namespace.typename) + /// and the other part identifying the assembly (assembly name, version, culture, publickey). + /// + /// + /// + private static string[] SplitStrongName(string strongName) + { + var index = -1; + var bcount = 0; + for (var i = 0; i < strongName.Length; ++i) + { + if (strongName[i] == '[') + ++bcount; + else if (strongName[i] == ']') + --bcount; + else if (bcount == 0 && strongName[i] == ',') + { + index = i; + break; + } + } + + if (index == -1) + return new[] { strongName }; + + var typeName = strongName.Substring(0, index); + var what = strongName.Substring(index + 1); + return new[] { typeName, what }; + } + + private bool Equals(TypeName that) + { + return string.Equals(FullName, that.FullName); + } + + private static bool TryParseDeclaringType(string fullTypename, + out string declaringTypename, + out string innerTypename) + { + var index = fullTypename.IndexOf('+'); + if (index == -1) + { + declaringTypename = null; + innerTypename = null; + return false; + } + + declaringTypename = fullTypename.Substring(0, index); + innerTypename = fullTypename.Substring(index + 1); + return true; + } + + private static bool TryParseGenericTypeArguments(string fullTypename, + out string genericTypeDefinition, + out TypeName[] genericTypeArguments) + { + // + // Is it an array type such as Foo[]? + // + + if (fullTypename.EndsWith("[]")) + { + var arrayTypeName = fullTypename.Substring(0, fullTypename.Length - 2); + if (!TryParse(arrayTypeName, out var arrayType)) + { + genericTypeDefinition = null; + genericTypeArguments = null; + return false; + } + + genericTypeDefinition = "System.Array"; + genericTypeArguments = new[] { arrayType }; + return true; + } + + + // + // Find out how many arguments this type has, like in "blub`1[[" + // + + if (!TryParseNumberOfGenericTypeArguments(fullTypename, + out genericTypeDefinition, + out var firstArgumentIndex, + out var numTypeArguments)) + { + genericTypeArguments = null; + return false; + } + + genericTypeArguments = new TypeName[numTypeArguments]; + if (firstArgumentIndex <= fullTypename.Length) + { + // + // Parse each argument's typename as well.. + // + + for (var i = 0; i < numTypeArguments; ++i) + { + if (!TryExtractGenericTypeArgument(fullTypename, ref firstArgumentIndex, out var fullyQualifiedTypename)) + { + genericTypeArguments = null; + return false; + } + + if (!string.IsNullOrWhiteSpace(fullyQualifiedTypename)) + { + if (!TryParse(fullyQualifiedTypename, out var genericTypename)) + { + genericTypeArguments = null; + return false; + } + + genericTypeArguments[i] = genericTypename; + } + + var c = fullTypename[firstArgumentIndex]; + if (c == ',') + ++firstArgumentIndex; + } + } + + return true; + } + + private static string BuildFullName(TypeName genericTypeDefinition, IEnumerable genericTypeArguments) + { + var args = string.Join(", ", genericTypeArguments.Select(x => string.Format("[{0}]", x.FullName))); + + if (genericTypeDefinition._assemblyName == null) + return string.Format("{0}[{1}]", genericTypeDefinition._fullTypeNameWithNamespace, args); + + return string.Format("{0}[{1}], {2}", + genericTypeDefinition._fullTypeNameWithNamespace, + args, + genericTypeDefinition._assemblyName); + } + + #endregion + } +} \ No newline at end of file diff --git a/SharpRemote/CodeGeneration/TypeResolver.cs b/SharpRemote/CodeGeneration/TypeResolver.cs index 693e9b9..38155f2 100644 --- a/SharpRemote/CodeGeneration/TypeResolver.cs +++ b/SharpRemote/CodeGeneration/TypeResolver.cs @@ -11,53 +11,48 @@ public static class TypeResolver { private static readonly Dictionary Cache; +#if NET6_0 + private static readonly TypeLoader TypeLoader = new TypeLoader(); +#endif + static TypeResolver() { Cache = new Dictionary(); } - /// - /// Resolves the type for the given name. - /// - /// - /// - [Pure] - public static Type GetType(string name) - { - lock (Cache) - { - Type value; - if (!Cache.TryGetValue(name, out value)) - { - value = Type.GetType(name); - Cache.Add(name, value); - } - return value; - } - } - /// /// Resolves the type for the given name. /// /// /// - /// The given type with the given name or null in case no such type could be found + /// [Pure] - public static Type GetType(string name, bool throwOnError) + public static Type GetType(string name, bool throwOnError = false) { lock (Cache) { - Type value; - if (!Cache.TryGetValue(name, out value)) + if (!Cache.TryGetValue(name, out var value)) { - value = Type.GetType(name, throwOnError); + value = LoadType(name, throwOnError); if (value == null) return null; Cache.Add(name, value); } + return value; } } + + private static Type LoadType(string name, bool throwOnError) + { +#if NET6_0 + var typeName = TypeName.Parse(name); + // in .NET 6 the assembly is not loaded automatically + return TypeLoader.LoadType(typeName.FullTypeNameWithNamespace, typeName.AssemblyName, throwOnError); +#else + return Type.GetType(name, throwOnError); +#endif + } } } \ No newline at end of file diff --git a/SharpRemote/EndPoints/AbstractBinaryStreamEndPoint.cs b/SharpRemote/EndPoints/AbstractBinaryStreamEndPoint.cs index 97e43ee..d31b393 100644 --- a/SharpRemote/EndPoints/AbstractBinaryStreamEndPoint.cs +++ b/SharpRemote/EndPoints/AbstractBinaryStreamEndPoint.cs @@ -393,6 +393,10 @@ public void Dispose() _servants.Dispose(); _isDisposed = true; + + CollectGarbage(null); + + Log.Info("AbstractBinaryStreamEndPoint is disposed now!"); } finally { @@ -468,6 +472,12 @@ public IServant GetExistingOrCreateNewServant(T subject) where T : class return _servants.GetExistingOrCreateNewServant(subject); } + /// + public IServant GetExistingOrCreateNewServant(ulong objectId, T subject) where T : class + { + return _servants.GetExistingOrCreateNewServant(objectId, subject); + } + /// /// Is called when a connection with another /// is created. @@ -1404,11 +1414,11 @@ private bool TryReadMessage(TTransport socket, string messageStep, out string messageType, out string message, - out string error) + out string error, + out EndPointDisconnectReason disconnectReason) { EndPoint remoteEndPoint = GetRemoteEndPointOf(socket); var size = new byte[4]; - EndPointDisconnectReason disconnectReason; if (!SynchronizedRead(socket, size, timeout, out disconnectReason)) { messageType = null; @@ -1500,16 +1510,22 @@ private bool SendGoodbye(TTransport socket, TimeSpan waitTime) /// /// /// + /// + /// /// protected void ReadMessage(TTransport socket, TimeSpan timeout, string messageStep, out string messageType, - out string message) + out string message, + out string error, + out EndPointDisconnectReason errorReason) { - string error; - if (!TryReadMessage(socket, timeout, messageStep, out messageType, out message, out error)) + if (!TryReadMessage(socket, timeout, messageStep, out messageType, out message, out error, out errorReason)) { + if (errorReason == EndPointDisconnectReason.ConnectionTimedOut) + throw new HandshakeTimeoutException(error); + throw new HandshakeException(error); } } @@ -1525,9 +1541,11 @@ protected void WriteMessage(TTransport socket, string messageType, string message = "") { - string error; - if (!TryWriteMessage(socket, messageType, message, out error)) + if (!TryWriteMessage(socket, messageType, message, out var error, out var errorReason)) { + if (errorReason == EndPointDisconnectReason.ConnectionTimedOut) + throw new HandshakeTimeoutException(error); + throw new HandshakeException(error); } } @@ -1535,7 +1553,8 @@ protected void WriteMessage(TTransport socket, private bool TryWriteMessage(TTransport socket, string messageType, string message, - out string error) + out string error, + out EndPointDisconnectReason errorReason) { EndPoint remoteEndPoint = GetRemoteEndPointOf(socket); using (var stream = new MemoryStream()) @@ -1547,16 +1566,15 @@ private bool TryWriteMessage(TTransport socket, writer.Flush(); PatchResponseMessageLength(stream, writer); stream.Position = 0; - - EndPointDisconnectReason disconnectReason; - if (!SynchronizedWrite(socket, stream.GetBuffer(), (int) stream.Length, out disconnectReason)) + + if (!SynchronizedWrite(socket, stream.GetBuffer(), (int) stream.Length, out errorReason)) { error = string.Format("{0}: EndPoint '{1}' failed to send {2} to remote endpoint '{3}': {4}", Name, InternalLocalEndPoint, messageType, remoteEndPoint, - disconnectReason); + errorReason); return false; } } @@ -1592,6 +1610,8 @@ protected ConnectionId PerformIncomingHandshake(TTransport socket, EndPoint remo TimeSpan timeout = TimeSpan.FromMinutes(1); string messageType; string message; + string error; + EndPointDisconnectReason errorReason; if (_clientAuthenticator != null) { @@ -1601,7 +1621,7 @@ protected ConnectionId PerformIncomingHandshake(TTransport socket, EndPoint remo Log.DebugFormat("{0}: Creating challenge '{1}' for endpoint '{2}'", Name, challenge, remoteEndPoint); WriteMessage(socket, AuthenticationRequiredMessage, challenge); - ReadMessage(socket, timeout, AuthenticationResponse, out messageType, out message); + ReadMessage(socket, timeout, AuthenticationResponse, out messageType, out message, out error, out errorReason); Log.DebugFormat("{0}: Received response '{1}' for challenge '{2}' from endpoint '{3}'", Name, message, @@ -1627,7 +1647,7 @@ protected ConnectionId PerformIncomingHandshake(TTransport socket, EndPoint remo WriteMessage(socket, NoAuthenticationRequiredMessage); } - ReadMessage(socket, timeout, AuthenticationChallenge, out messageType, out message); + ReadMessage(socket, timeout, AuthenticationChallenge, out messageType, out message, out error, out errorReason); if (messageType == AuthenticationRequiredMessage) { if (_serverAuthenticator == null) @@ -1639,12 +1659,15 @@ protected ConnectionId PerformIncomingHandshake(TTransport socket, EndPoint remo // After having answered the challenge we wait for a successful response from the client. // If we failed the authentication, then - ReadMessage(socket, timeout, AuthenticationVerification, out messageType, out message); + ReadMessage(socket, timeout, AuthenticationVerification, out messageType, out message, out error, out errorReason); if (messageType != AuthenticationSucceedMessage) throw new AuthenticationException(string.Format("Failed to authenticate against endpoint '{0}'", remoteEndPoint)); } else if (messageType != NoAuthenticationRequiredMessage) { + if (errorReason == EndPointDisconnectReason.ConnectionTimedOut) + throw new HandshakeTimeoutException(error); + throw new HandshakeException(); } @@ -1663,25 +1686,26 @@ protected ConnectionId PerformIncomingHandshake(TTransport socket, EndPoint remo /// /// /// + /// protected bool TryPerformOutgoingHandshake(TTransport socket, TimeSpan timeout, out ErrorType errorType, out string error, out ConnectionId currentConnectionId, - out object errorReason) + out EndPointDisconnectReason errorReason, + out EndPoint blockeIpEndPoint) { - string messageType; - string message; EndPoint remoteEndPoint = GetRemoteEndPointOf(socket); if (!TryReadMessage(socket, timeout, AuthenticationChallenge, - out messageType, - out message, - out error)) + out var messageType, + out var message, + out error, + out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1696,7 +1720,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, errorType = ErrorType.AuthenticationRequired; error = string.Format("Endpoint '{0}' requires authentication", remoteEndPoint); currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1709,11 +1733,11 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, // Upon establishing a connection, we try to authenticate the ourselves // against the server by answering his response. string response = _clientAuthenticator.CreateResponse(challenge); - if (!TryWriteMessage(socket, AuthenticationResponseMessage, response, out error)) + if (!TryWriteMessage(socket, AuthenticationResponseMessage, response, out error, out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1722,11 +1746,12 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, if (!TryReadMessage(socket, timeout, AuthenticationVerification, out messageType, out message, - out error)) + out error, + out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1735,7 +1760,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, errorType = ErrorType.Authentication; error = string.Format("Failed to authenticate against endpoint '{0}'", remoteEndPoint); currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } } @@ -1746,7 +1771,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, else if (messageType == EndPointBlocked) { errorType = ErrorType.EndPointBlocked; - errorReason = TryParseEndPoint(message); + blockeIpEndPoint = TryParseEndPoint(message); error = string.Format("{0}: EndPoint '{1}' is already connected to '{2}' and doesn't accept any other connection until the current one is disconnected", Name, @@ -1768,7 +1793,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, NoAuthenticationRequiredMessage ); currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1777,22 +1802,23 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, // After we've authenticated ourselves, it's time for the server to authenticate himself. // Let's send the challenge string challenge = _serverAuthenticator.CreateChallenge(); - if (!TryWriteMessage(socket, AuthenticationRequiredMessage, challenge, out error)) + if (!TryWriteMessage(socket, AuthenticationRequiredMessage, challenge, out error, out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } if (!TryReadMessage(socket, timeout, AuthenticationResponse, out messageType, out message, - out error)) + out error, + out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1805,15 +1831,15 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, error = string.Format("Remote endpoint '{0}' failed the authentication challenge", remoteEndPoint); currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } - if (!TryWriteMessage(socket, AuthenticationSucceedMessage, "", out error)) + if (!TryWriteMessage(socket, AuthenticationSucceedMessage, "", out error, out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1826,11 +1852,11 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, WriteMessage(socket, NoAuthenticationRequiredMessage); } - if (!TryReadMessage(socket, timeout, AuthenticationFinished, out messageType, out message, out error)) + if (!TryReadMessage(socket, timeout, AuthenticationFinished, out messageType, out message, out error, out errorReason)) { errorType = ErrorType.Handshake; currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1845,7 +1871,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, HandshakeSucceedMessage, messageType); currentConnectionId = ConnectionId.None; - errorReason = null; + blockeIpEndPoint = null; return false; } @@ -1853,7 +1879,7 @@ protected bool TryPerformOutgoingHandshake(TTransport socket, currentConnectionId = OnHandshakeSucceeded(socket, remoteEndPoint); errorType = ErrorType.Handshake; error = null; - errorReason = null; + blockeIpEndPoint = null; return true; } diff --git a/SharpRemote/EndPoints/NamedPipes/NamedPipeRemotingEndPointClient.cs b/SharpRemote/EndPoints/NamedPipes/NamedPipeRemotingEndPointClient.cs index 99b4329..8353de9 100644 --- a/SharpRemote/EndPoints/NamedPipes/NamedPipeRemotingEndPointClient.cs +++ b/SharpRemote/EndPoints/NamedPipes/NamedPipeRemotingEndPointClient.cs @@ -139,14 +139,17 @@ public bool TryConnect(NamedPipeEndPoint endPoint, TimeSpan timeout, out Excepti } var remaining = timeout - (DateTime.Now - started); - ErrorType errorType; - string error; - object errorReason; - if (!TryPerformOutgoingHandshake(pipe, remaining, out errorType, out error, out connectionId, out errorReason)) + if (!TryPerformOutgoingHandshake(pipe, remaining, out ErrorType errorType, out string error, out connectionId, out var errorReason, out var blockedIpEndpoint)) { switch (errorType) { case ErrorType.Handshake: + if (errorReason == EndPointDisconnectReason.ConnectionTimedOut) + { + exception = new HandshakeTimeoutException(error); + break; + } + exception = new HandshakeException(error); break; @@ -155,7 +158,7 @@ public bool TryConnect(NamedPipeEndPoint endPoint, TimeSpan timeout, out Excepti break; case ErrorType.EndPointBlocked: - exception = new RemoteEndpointAlreadyConnectedException(error, errorReason as EndPoint); + exception = new RemoteEndpointAlreadyConnectedException(error, blockedIpEndpoint?.ToString()); break; default: diff --git a/SharpRemote/EndPoints/ServantStorage.cs b/SharpRemote/EndPoints/ServantStorage.cs index 0c0fe2c..b807c74 100644 --- a/SharpRemote/EndPoints/ServantStorage.cs +++ b/SharpRemote/EndPoints/ServantStorage.cs @@ -140,6 +140,20 @@ public IServant GetExistingOrCreateNewServant(T subject) where T : class } } + public IServant GetExistingOrCreateNewServant(ulong objectId, T subject) where T : class + { + lock (_syncRoot) + { + IServant servant; + if (!_servantsBySubject.TryGetValue(subject, out servant)) + { + servant = CreateServant(objectId, subject); + } + + return servant; + } + } + public int RemoveUnusedServants() { lock (_syncRoot) diff --git a/SharpRemote/EndPoints/Sockets/ISocketEndPoint.cs b/SharpRemote/EndPoints/Sockets/ISocketEndPoint.cs index 33d1f0b..a15acec 100644 --- a/SharpRemote/EndPoints/Sockets/ISocketEndPoint.cs +++ b/SharpRemote/EndPoints/Sockets/ISocketEndPoint.cs @@ -184,6 +184,9 @@ bool TryConnect(IPEndPoint endPoint, /// /// - The given endPoint requires authentication, but this one didn't provide any /// + /// + /// - The given endPoint requires authentication, but authentication times out during the process + /// /// /// - The handshake between this and the given endpoint failed /// diff --git a/SharpRemote/EndPoints/Sockets/SocketEndPoint.cs b/SharpRemote/EndPoints/Sockets/SocketEndPoint.cs index a2678b2..85bee47 100644 --- a/SharpRemote/EndPoints/Sockets/SocketEndPoint.cs +++ b/SharpRemote/EndPoints/Sockets/SocketEndPoint.cs @@ -311,14 +311,17 @@ public bool TryConnect(IPEndPoint endPoint, } var remaining = timeout - (DateTime.Now - started); - ErrorType errorType; - string error; - object errorReason; - if (!TryPerformOutgoingHandshake(socket, remaining, out errorType, out error, out connectionId, out errorReason)) + if (!TryPerformOutgoingHandshake(socket, remaining, out var errorType, out var error, out connectionId, out var errorReason, out var blockedIpEndpoint)) { switch (errorType) { case ErrorType.Handshake: + if (errorReason == EndPointDisconnectReason.ConnectionTimedOut) + { + exception = new HandshakeTimeoutException(error); + break; + } + exception = new HandshakeException(error); break; @@ -327,7 +330,7 @@ public bool TryConnect(IPEndPoint endPoint, break; case ErrorType.EndPointBlocked: - exception = new RemoteEndpointAlreadyConnectedException(error, errorReason as IPEndPoint); + exception = new RemoteEndpointAlreadyConnectedException(error, blockedIpEndpoint?.ToString()); break; default: @@ -355,8 +358,22 @@ public bool TryConnect(IPEndPoint endPoint, { if (socket != null) { - socket.Close(); - socket.TryDispose(); + try + { + if (socket.Connected) + { + socket.Shutdown(SocketShutdown.Both); + } + + socket.Close(); + socket.TryDispose(); + } + catch (Exception e) + { + Log.WarnFormat("{0}: Ignoring exception caught while closing & disposing of socket: {1}", + Name, + e); + } } RemoteEndPoint = null; @@ -406,6 +423,7 @@ public ConnectionId Connect(string endPointName, TimeSpan timeout) if (TryConnect(result.EndPoint, timeout, out e, out connectionId)) return connectionId; } + // ReSharper disable once PossibleNullReferenceException throw e; } @@ -461,6 +479,9 @@ public ConnectionId Connect(IPEndPoint endPoint) /// /// - The given endPoint requires authentication, but this one didn't provide any /// + /// + /// - The handshake between this and the given endpoint failed due to a time out during the process + /// /// /// - The handshake between this and the given endpoint failed /// @@ -561,6 +582,11 @@ internal void Bind(ISocket serverSocket) Listen(); } + /// + /// This event is invoked whenever there is an exception being thrown during serving socket is established. + /// + public event Action OnBindException; + private bool TryConnect(string endPointName, TimeSpan timeout, out Exception exception, out ConnectionId connectionId) { if (endPointName == null) throw new ArgumentNullException(nameof(endPointName)); @@ -893,6 +919,7 @@ internal void OnIncomingConnection(ISocket serverSocket, IAsyncResult ar) Log.WarnFormat("{0}: Caught exception while accepting incoming connection: {1}", Name, e); + EmitBindException(e); // NOTE: We don't want to disconnect anything here because we might already have a // working connection with another client. It's just that this new client // caused us trouble (which is why we dispose of the socket in the finally @@ -903,6 +930,7 @@ internal void OnIncomingConnection(ISocket serverSocket, IAsyncResult ar) Log.ErrorFormat("{0}: Caught exception while accepting incoming connection: {1}", Name, e); + EmitBindException(e); // NOTE: We don't want to disconnect anything here because we might already have a // working connection with another client. It's just that this new client // caused us trouble (which is why we dispose of the socket in the finally @@ -916,15 +944,21 @@ internal void OnIncomingConnection(ISocket serverSocket, IAsyncResult ar) { try { - socket.Shutdown(SocketShutdown.Both); - socket.Disconnect(reuseSocket: false); - socket.Dispose(); + if (socket.Connected) + { + socket.Shutdown(SocketShutdown.Both); + socket.Disconnect(reuseSocket: false); + } + + socket.Close(); + socket.TryDispose(); } catch (Exception e) { Log.WarnFormat("{0}: Ignoring exception caught while disconnecting & disposing of socket: {1}", Name, e); + EmitBindException(e); } } } @@ -953,6 +987,7 @@ private void TryEstablishConnectionWith(ISocket socket, ref bool success) // We need to undo anything we did above Disconnect(); + EmitBindException(e); } catch (Exception e) { @@ -962,7 +997,14 @@ private void TryEstablishConnectionWith(ISocket socket, ref bool success) // We need to undo anything we did above Disconnect(); + EmitBindException(e); } } + + private void EmitBindException(Exception ex) + { + var fn = OnBindException; + fn?.Invoke(ex); + } } } \ No newline at end of file diff --git a/SharpRemote/EndPoints/Sockets/SocketSettings.cs b/SharpRemote/EndPoints/Sockets/SocketSettings.cs index bcf8605..74159e0 100644 --- a/SharpRemote/EndPoints/Sockets/SocketSettings.cs +++ b/SharpRemote/EndPoints/Sockets/SocketSettings.cs @@ -99,7 +99,7 @@ public static ushort MaxUserPort { const int defaultValue = 65535; -#if DOTNETCORE +#if NET6_0 return defaultValue; #else try @@ -124,7 +124,7 @@ public static TimeSpan TcpTimedWaitDelay { const int defaultValue = 120; -#if DOTNETCORE +#if NET6_0 return TimeSpan.FromSeconds(defaultValue); #else try diff --git a/SharpRemote/Exceptions/ConnectionLostException.cs b/SharpRemote/Exceptions/ConnectionLostException.cs index 5635031..2c9af87 100644 --- a/SharpRemote/Exceptions/ConnectionLostException.cs +++ b/SharpRemote/Exceptions/ConnectionLostException.cs @@ -24,16 +24,6 @@ public class ConnectionLostException /// public readonly string EndPointName; - /// - /// The address of the local endpoint which lost the connection. - /// - public readonly EndPoint LocalEndPoint; - - /// - /// The address of the endpoint to which the connection has been lost. - /// - public readonly EndPoint RemoteEndPoint; - /// /// Deserialization ctor. /// @@ -45,8 +35,6 @@ public ConnectionLostException(SerializationInfo info, StreamingContext context) try { EndPointName = info.GetString("EndPointName"); - LocalEndPoint = info.GetValue("LocalEndPoint", typeof(EndPoint)) as EndPoint; - RemoteEndPoint = info.GetValue("RemoteEndPoint", typeof(EndPoint)) as EndPoint; } catch (Exception e) { @@ -66,14 +54,10 @@ public ConnectionLostException() /// Initializes a new instance of this exception. /// /// - /// - /// - public ConnectionLostException(string endPointName, EndPoint localEndPoint = null, EndPoint remoteEndPoint = null) + public ConnectionLostException(string endPointName) : base("The connection to the remote endpoint has been lost") { EndPointName = endPointName; - LocalEndPoint = localEndPoint; - RemoteEndPoint = remoteEndPoint; } /// @@ -82,8 +66,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("EndPointName", EndPointName); - info.AddValue("LocalEndPoint", LocalEndPoint); - info.AddValue("RemoteEndPoint", RemoteEndPoint); } } } \ No newline at end of file diff --git a/SharpRemote/Exceptions/HandshakeTimeoutException.cs b/SharpRemote/Exceptions/HandshakeTimeoutException.cs new file mode 100644 index 0000000..5f11f03 --- /dev/null +++ b/SharpRemote/Exceptions/HandshakeTimeoutException.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.Serialization; + +// ReSharper disable CheckNamespace +namespace SharpRemote +// ReSharper restore CheckNamespace +{ + /// + /// + /// + [Serializable] + public class HandshakeTimeoutException + : AuthenticationException + { + /// + /// Deserialization ctor. + /// + /// + /// + public HandshakeTimeoutException(SerializationInfo info, StreamingContext context) + : base(info, context) + {} + + /// + /// Initializes a new instance of this exception. + /// + public HandshakeTimeoutException() + {} + + /// + /// Initializes a new instance of this exception with the given message and inner exception that + /// is the cause of this exception. + /// + /// + /// + public HandshakeTimeoutException(string message, Exception innerException = null) + : base(message, innerException) + { + + } + } +} \ No newline at end of file diff --git a/SharpRemote/Exceptions/RemoteEndpointAlreadyConnectedException.cs b/SharpRemote/Exceptions/RemoteEndpointAlreadyConnectedException.cs index e589fca..f00d9d3 100644 --- a/SharpRemote/Exceptions/RemoteEndpointAlreadyConnectedException.cs +++ b/SharpRemote/Exceptions/RemoteEndpointAlreadyConnectedException.cs @@ -1,5 +1,4 @@ using System; -using System.Net; using System.Runtime.Serialization; // ReSharper disable CheckNamespace @@ -30,7 +29,7 @@ public RemoteEndpointAlreadyConnectedException() public RemoteEndpointAlreadyConnectedException(SerializationInfo info, StreamingContext context) : base(info, context) { - BlockingEndPoint = info.GetValue("BlockingEndPoint", typeof(EndPoint)) as EndPoint; + BlockingEndPointName = info.GetValue("BlockingEndPointName", typeof(string)) as string; } /// @@ -38,27 +37,27 @@ public RemoteEndpointAlreadyConnectedException(SerializationInfo info, Streaming /// for this exception. /// /// - /// The endpoint responsible for not being able to establish a connection + /// The endpoint responsible for not being able to establish a connection /// public RemoteEndpointAlreadyConnectedException(string message, - EndPoint blockingEndPoint, + string blockingEndPointName, Exception innerException = null) : base(message, innerException) { - BlockingEndPoint = blockingEndPoint; + BlockingEndPointName = blockingEndPointName; } /// /// The endpoint responsible for not being able to establish a connection. /// - public EndPoint BlockingEndPoint { get; set; } + public string BlockingEndPointName { get; set; } /// public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("BlockingEndPoint", BlockingEndPoint); + info.AddValue("BlockingEndPointName", BlockingEndPointName); } } } \ No newline at end of file diff --git a/SharpRemote/Extensions/AssemblyExtensions.cs b/SharpRemote/Extensions/AssemblyExtensions.cs deleted file mode 100644 index 1eae377..0000000 --- a/SharpRemote/Extensions/AssemblyExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.IO; -using System.Reflection; - -namespace SharpRemote.Extensions -{ - internal static class AssemblyExtensions - { - public static string GetDirectory(this Assembly assembly) - { - string codeBase = assembly.CodeBase; - var uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); - } - } -} diff --git a/SharpRemote/Extensions/ByteArrayExtensions.cs b/SharpRemote/Extensions/ByteArrayExtensions.cs deleted file mode 100644 index a816781..0000000 --- a/SharpRemote/Extensions/ByteArrayExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace SharpRemote.Extensions -{ - /// - /// Extensions to the byte array. - /// - public static class ByteArrayExtensions - { - /// - /// Prints the contents of this array as a c# statement in the form of - /// "var data = new byte[]{ content }". - /// - /// - public static void Print(this byte[] that) - { - var hex = BitConverter.ToString(that).Replace("-", ", 0x"); - Console.WriteLine("var data = new byte[]{0};", "{0x" + hex + "}"); - } - } -} \ No newline at end of file diff --git a/SharpRemote/SharpRemote.csproj b/SharpRemote/SharpRemote.csproj index 9fdcf5f..df13040 100644 --- a/SharpRemote/SharpRemote.csproj +++ b/SharpRemote/SharpRemote.csproj @@ -1,335 +1,11 @@ - - - + - Debug - AnyCPU - {1B908B3A-2F3B-47B8-B69F-3827B8829586} - Library - Properties - SharpRemote - SharpRemote - v4.5 - 512 - + net48;net6.0 + ..\bin + false + true - - true - full - false - ..\bin\win\ - DEBUG;TRACE - prompt - 4 - ..\bin\win\SharpRemote.XML - true - - - pdbonly - true - ..\bin\win\ - TRACE - prompt - 4 - ..\bin\\win\SharpRemote.XML - true - - - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - + - - - \ No newline at end of file diff --git a/SharpRemote/SharpRemote.nuspec b/SharpRemote/SharpRemote.nuspec index b684f2d..d16a7ed 100644 --- a/SharpRemote/SharpRemote.nuspec +++ b/SharpRemote/SharpRemote.nuspec @@ -17,14 +17,22 @@ Copyright 2017 .NET Remoting RPC - + + - - - - - + + + + + + + + + + + + diff --git a/SharpRemote/Sockets/ISocket.cs b/SharpRemote/Sockets/ISocket.cs index 7b912cd..0eb29d6 100644 --- a/SharpRemote/Sockets/ISocket.cs +++ b/SharpRemote/Sockets/ISocket.cs @@ -318,19 +318,7 @@ public interface ISocket /// when an attempt was made to set TTL to a value higher than 255. /// The System.Net.Sockets.Socket has been closed. short Ttl { get; set; } - - /// - /// Specifies whether the socket should only use Overlapped I/O mode. - /// - /// - /// true if the System.Net.Sockets.Socket uses only overlapped I/O; otherwise, false. - /// The default is false. - /// - /// - /// The socket has been bound to a completion port. - /// - bool UseOnlyOverlappedIO { get; set; } - + /// /// Creates a new System.Net.Sockets.Socket for a newly created connection. /// diff --git a/SharpRemote/Sockets/Socket2.cs b/SharpRemote/Sockets/Socket2.cs index 0ee8e21..13826cc 100644 --- a/SharpRemote/Sockets/Socket2.cs +++ b/SharpRemote/Sockets/Socket2.cs @@ -176,13 +176,6 @@ public short Ttl set { _socket.Ttl = value; } } - /// - public bool UseOnlyOverlappedIO - { - get { return _socket.UseOnlyOverlappedIO; } - set { _socket.UseOnlyOverlappedIO = value; } - } - /// public ISocket Accept() { diff --git a/SharpRemote/WeakKeyDictionary.cs b/SharpRemote/WeakKeyDictionary.cs index 14fcfca..65bfe63 100644 --- a/SharpRemote/WeakKeyDictionary.cs +++ b/SharpRemote/WeakKeyDictionary.cs @@ -77,6 +77,7 @@ private void Initialize(int capacity) for (int i = 0; i < _buckets.Length; i++) _buckets[i] = -1; _entries = new Entry[size]; _freeList = -1; + _freeCount = 0; } /// @@ -407,6 +408,8 @@ public void Clear() } } Initialize(0); + _version = 0; + _count = 0; } public void Dispose() diff --git a/SharpRemote/packages.config b/SharpRemote/packages.config deleted file mode 100644 index 6419ef8..0000000 --- a/SharpRemote/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file