From: Adam Sitnik Date: Mon, 16 Dec 2019 23:59:19 +0000 (+0100) Subject: add .NET Standard 2.0 for diagnostics client library (#700) X-Git-Tag: submit/tizen_5.5/20200504.045052~11^2^2~207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95368227750a8c66f55f2e064409bab028b2f6e8;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git add .NET Standard 2.0 for diagnostics client library (#700) --- diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs index 7d309b670..1ab6409ea 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs @@ -4,15 +4,13 @@ using System; using System.Diagnostics; -using System.Collections.Generic; using System.IO; using System.IO.Pipes; using System.Linq; +using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Security.Principal; -using System.Text; -using System.Text.RegularExpressions; namespace Microsoft.Diagnostics.NETCore.Client { @@ -69,7 +67,7 @@ namespace Microsoft.Diagnostics.NETCore.Client throw new ServerNotAvailableException($"Process {processId} not running compatible .NET Core runtime."); } string path = Path.Combine(IpcRootPath, ipcPort); - var remoteEP = new UnixDomainSocketEndPoint(path); + var remoteEP = CreateUnixDomainSocketEndPoint(path); var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); socket.Connect(remoteEP); @@ -122,5 +120,17 @@ namespace Microsoft.Diagnostics.NETCore.Client { return IpcMessage.Parse(stream); } + + private static EndPoint CreateUnixDomainSocketEndPoint(string path) + { +#if NETCOREAPP + return new UnixDomainSocketEndPoint(path); +#elif NETSTANDARD2_0 + // UnixDomainSocketEndPoint is not part of .NET Standard 2.0 + var type = typeof(Socket).Assembly.GetType("System.Net.Sockets.UnixDomainSocketEndPoint"); + var ctor = type.GetConstructor(new[] { typeof(string) }); + return (EndPoint)ctor.Invoke(new object[] { path }); +#endif + } } } diff --git a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj index dcb33ec0f..b30d9e8f6 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj +++ b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj @@ -1,7 +1,7 @@  Library - netcoreapp2.1 + netstandard2.0;netcoreapp2.1 Microsoft.Diagnostics.NETCore.Client .NET Core Diagnostics Client Library 0.1.0