From 36bd2c032ffc67596b8a0da7a83b7e180f7073e1 Mon Sep 17 00:00:00 2001 From: Nathan Holland Date: Wed, 1 Nov 2017 23:37:51 +1300 Subject: [PATCH] Use platform detection that works on mono 4.6+ (#2055) --- src/CurlSharp/CurlSharp.csproj | 11 +---------- src/CurlSharp/NativeMethods.cs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/CurlSharp/CurlSharp.csproj b/src/CurlSharp/CurlSharp.csproj index df315101e..032a2b685 100644 --- a/src/CurlSharp/CurlSharp.csproj +++ b/src/CurlSharp/CurlSharp.csproj @@ -1,7 +1,7 @@  - net452;netstandard1.5 + net452;netstandard2.0 @@ -9,13 +9,4 @@ CurlSharp false - - - - - - - - - \ No newline at end of file diff --git a/src/CurlSharp/NativeMethods.cs b/src/CurlSharp/NativeMethods.cs index f97a57a51..0d9243288 100644 --- a/src/CurlSharp/NativeMethods.cs +++ b/src/CurlSharp/NativeMethods.cs @@ -46,16 +46,16 @@ namespace CurlSharp static NativeMethods() { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { - switch (RuntimeInformation.OSArchitecture) + if (Environment.Is64BitOperatingSystem) { - case Architecture.X64: - SetDllDirectory(Path.Combine(AssemblyDirectory, LIB_DIR_WIN64)); - break; - case Architecture.X86: - SetDllDirectory(Path.Combine(AssemblyDirectory, LIB_DIR_WIN32)); - break; + SetDllDirectory(Path.Combine(AssemblyDirectory, LIB_DIR_WIN64)); + } + else + { + SetDllDirectory(Path.Combine(AssemblyDirectory, LIB_DIR_WIN32)); } } #if USE_LIBCURLSHIM @@ -63,11 +63,11 @@ namespace CurlSharp throw new InvalidOperationException("Can not run on other platform than Win NET"); #endif } - + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetDllDirectory(string lpPathName); - + private static string AssemblyDirectory { get @@ -334,7 +334,7 @@ namespace CurlSharp { var handle = Create(); handle.fd_count = 1; - handle.fd_array[0] = (uint) socket; + handle.fd_array[0] = (uint)socket; return handle; } } @@ -400,7 +400,7 @@ namespace CurlSharp { int result; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { result = select_win( nfds, // number of sockets, (ignored in winsock)