Commit 3ed0e0d4 authored by Jeremy Meng's avatar Jeremy Meng Committed by Nick Craver

Add netstandard2.0 support (#767)

* Add netstandard2.0 target to SE.Redis projects

Two new conditional compilation constants are introduced:

* FEATURE_PERFCOUNTER - supported in net45 and net46
* FEATURE_THREADPOOL - supported in net45, net46, and netstandard2.0

* Add netcoreapp2.0 target framework to test projects

* Replace CORE_CLR conditional compilation symbol

with built-in NETSTANDARD1_5 or NETCOREAPP1_0 since now netstandard2.0
is also supported.

* Remove unnecessary conditional compilation constants
parent e4d3a782
......@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFrameworks>netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<AssemblyName>BasicTest</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>BasicTest</PackageId>
......@@ -14,10 +14,6 @@
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageReference Include="System.Console" Version="$(CoreFxVersion)" />
</ItemGroup>
......
......@@ -22,7 +22,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<IncludeSymbols>false</IncludeSymbols>
<LibraryTargetFrameworks>net45;net46;netstandard1.5</LibraryTargetFrameworks>
<LibraryTargetFrameworks>net45;net46;netstandard1.5;netstandard2.0</LibraryTargetFrameworks>
<CoreFxVersion>4.3.0</CoreFxVersion>
<xUnitVersion>2.4.0-beta.1.build3958</xUnitVersion>
</PropertyGroup>
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
......
......@@ -21,16 +21,16 @@
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net46'">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL;FEATURE_PERFCOUNTER;FEATURE_THREADPOOL</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.Compression" Version="$(CoreFxVersion)" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_THREADPOOL</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Collections.NonGeneric" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Net.NameResolution" Version="$(CoreFxVersion)" />
......@@ -41,4 +41,10 @@
<PackageReference Include="System.Threading.Thread" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading.ThreadPool" Version="$(CoreFxVersion)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="$(CoreFxVersion)" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -231,12 +231,12 @@ public async Task MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
RedisKey key = "MBOA";
var conn = muxer.GetDatabase();
await conn.PingAsync().ForAwait();
#if CORE_CLR
#if NETCOREAPP1_0
int number = 0;
#endif
Action<Task> nonTrivial = delegate
{
#if !CORE_CLR
#if !NETCOREAPP1_0
Thread.SpinWait(5);
#else
for (int i = 0; i < 50; i++)
......
#if FEATURE_MOQ
using Moq;
using Moq;
using StackExchange.Redis.KeyspaceIsolation;
using System.Text;
using Xunit;
......@@ -25,4 +24,3 @@ public void Execute()
}
}
}
#endif
\ No newline at end of file
......@@ -4,7 +4,7 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
#if !CORE_CLR
#if !NETCOREAPP1_0
using System.Security.Authentication;
#endif
......@@ -106,7 +106,7 @@ public void CreateDisconnectedNonsenseConnection_DNS()
}
}
#if !CORE_CLR
#if !NETCOREAPP1_0
[Fact]
public void SslProtocols_SingleValue()
{
......
......@@ -161,7 +161,7 @@ public void ReadConfig()
var all = conn.ConfigGet();
Assert.True(all.Length > 0, "any");
#if !CORE_CLR
#if !NETCOREAPP1_0
var pairs = all.ToDictionary(x => (string)x.Key, x => (string)x.Value, StringComparer.InvariantCultureIgnoreCase);
#else
var pairs = all.ToDictionary(x => (string)x.Key, x => (string)x.Value, StringComparer.OrdinalIgnoreCase);
......
#if FEATURE_MOQ
using System;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
......@@ -931,4 +930,3 @@ public void StringSetRange()
}
}
}
#endif
\ No newline at end of file
......@@ -2,7 +2,7 @@
using Jil;
using System;
using System.Collections.Generic;
#if CORE_CLR
#if NETCOREAPP1_0
using System.Reflection;
#endif
......
......@@ -168,7 +168,7 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
Type[] args = pFrom.Select(x => x.ParameterType).ToArray();
Output.WriteLine("Checking: {0}.{1}", from.Name, method.Name);
Assert.Equal(typeof(CommandFlags), args.Last());
#if !CORE_CLR
#if !NETCOREAPP1_0
var found = to.GetMethod(huntName, flags, null, method.CallingConvention, args, null);
#else
var found = to.GetMethods(flags)
......@@ -192,14 +192,14 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
private void CheckMethod(MethodInfo method, bool isAsync)
{
#if DEBUG
#if !CORE_CLR
#if !NETCOREAPP1_0
bool ignorePrefix = ignoreType != null && Attribute.IsDefined(method, ignoreType);
#else
bool ignorePrefix = ignoreType != null && method.IsDefined(ignoreType);
#endif
if (ignorePrefix)
{
#if !CORE_CLR
#if !NETCOREAPP1_0
Attribute attrib = Attribute.GetCustomAttribute(method, ignoreType);
#else
Attribute attrib = method.GetCustomAttribute(ignoreType);
......@@ -253,7 +253,7 @@ private void CheckName(MemberInfo member, bool isAsync)
public static class ReflectionExtensions
{
#if !CORE_CLR
#if !NETCOREAPP1_0
public static Type GetTypeInfo(this Type type)
{
return type;
......
using System;
using System.Collections.Generic;
using System.Linq;
#if CORE_CLR
#if NETCOREAPP1_0
using System.Reflection;
#endif
using System.Threading.Tasks;
......
......@@ -288,7 +288,7 @@ internal static class VolatileWrapper
{
public static int Read(ref int location)
{
#if !CORE_CLR
#if !NETCOREAPP1_0
return Thread.VolatileRead(ref location);
#else
return Volatile.Read(ref location);
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>StackExchange.Redis.Tests</Description>
<TargetFrameworks>net462;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
......@@ -13,13 +13,6 @@
<EmbeddedResource Include="*Config.json" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<DefineConstants>$(DefineConstants);FEATURE_MOQ</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);FEATURE_MOQ;CORE_CLR</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
<PackageReference Include="Jil" Version="2.15.4" />
......
......@@ -62,7 +62,7 @@ static TestBase()
{
Console.WriteLine("Unobserved: " + args.Exception);
args.SetObserved();
#if CORE_CLR
#if NETCOREAPP1_0
if (IgnorableExceptionPredicates.Any(predicate => predicate(args.Exception.InnerException))) return;
#endif
Interlocked.Increment(ref sharedFailCount);
......@@ -73,7 +73,7 @@ static TestBase()
};
}
#if CORE_CLR
#if NETCOREAPP1_0
private static readonly Func<Exception, bool>[] IgnorableExceptionPredicates = new Func<Exception, bool>[]
{
e => e != null && e is ObjectDisposedException && e.Message.Equals("Cannot access a disposed object.\r\nObject name: 'System.Net.Sockets.NetworkStream'."),
......@@ -326,7 +326,7 @@ protected static TimeSpan RunConcurrent(Action work, int threads, int timeout =
}
if (!allDone.WaitOne(timeout))
{
#if !CORE_CLR
#if !NETCOREAPP1_0
for (int i = 0; i < threads; i++)
{
var thd = threadArr[i];
......
#if FEATURE_MOQ
using System.Text;
using System.Text;
using Moq;
using StackExchange.Redis.KeyspaceIsolation;
......@@ -89,4 +88,3 @@ public void Execute()
}
#pragma warning restore RCS1047 // Non-asynchronous method name should not end with 'Async'.
}
#endif
\ No newline at end of file
#if FEATURE_MOQ
using System;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
......@@ -890,4 +889,3 @@ public void StringSetRangeAsync()
#pragma warning restore RCS1047 // Non-asynchronous method name should not end with 'Async'.
}
}
#endif
......@@ -16,16 +16,17 @@
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net46'">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<DefineConstants>$(DefineConstants);CORE_CLR</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_SOCKET_MODE_POLL;FEATURE_PERFCOUNTER;FEATURE_THREADPOOL</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.Compression" Version="$(CoreFxVersion)" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);FEATURE_SERIALIZATION;FEATURE_THREADPOOL</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Collections.NonGeneric" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Net.NameResolution" Version="$(CoreFxVersion)" />
......@@ -36,4 +37,10 @@
<PackageReference Include="System.Threading.Thread" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Threading.ThreadPool" Version="$(CoreFxVersion)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Reflection.Emit.ILGeneration" Version="$(CoreFxVersion)" />
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -17,7 +17,7 @@ public static class ConvertHelper
/// <returns></returns>
public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] source, Func<TInput, TOutput> selector)
{
#if CORE_CLR
#if NETSTANDARD1_5
TOutput[] arr = new TOutput[source.Length];
for(int i = 0 ; i < arr.Length ; i++)
arr[i] = selector(source[i]);
......
......@@ -4,7 +4,7 @@ internal static class VolatileWrapper
{
public static int Read(ref int location)
{
#if !CORE_CLR
#if !NETSTANDARD1_5
return System.Threading.Thread.VolatileRead(ref location);
#else
return System.Threading.Volatile.Read(ref location);
......@@ -13,7 +13,7 @@ public static int Read(ref int location)
public static void Write(ref int address, int value)
{
#if !CORE_CLR
#if !NETSTANDARD1_5
System.Threading.Thread.VolatileWrite(ref address, value);
#else
System.Threading.Volatile.Write(ref address, value);
......
......@@ -31,7 +31,7 @@ public enum Proxy
/// The options relevant to a set of redis connections
/// </summary>
public sealed class ConfigurationOptions
#if !CORE_CLR
#if !NETSTANDARD1_5
: ICloneable
#endif
{
......@@ -161,7 +161,7 @@ public static string TryNormalize(string value)
/// Indicates whether the connection should be encrypted
/// </summary>
[Obsolete("Please use .Ssl instead of .UseSsl"),
#if !CORE_CLR
#if !NETSTANDARD1_5
Browsable(false),
#endif
EditorBrowsable(EditorBrowsableState.Never)]
......@@ -386,7 +386,7 @@ public ConfigurationOptions Clone()
defaultDatabase = defaultDatabase,
ReconnectRetryPolicy = reconnectRetryPolicy,
preserveAsyncOrder = preserveAsyncOrder,
#if !CORE_CLR
#if !NETSTANDARD1_5
SslProtocols = SslProtocols,
#endif
};
......@@ -524,7 +524,7 @@ static void Append(StringBuilder sb, string prefix, object value)
}
}
#if !CORE_CLR
#if !NETSTANDARD1_5
static bool IsOption(string option, string prefix)
{
return option.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase);
......@@ -546,7 +546,7 @@ void Clear()
SocketManager = null;
}
#if !CORE_CLR
#if !NETSTANDARD1_5
object ICloneable.Clone() { return Clone(); }
#endif
......@@ -651,7 +651,7 @@ private void DoParse(string configuration, bool ignoreUnknown)
case OptionKeys.PreserveAsyncOrder:
PreserveAsyncOrder = OptionKeys.ParseBoolean(key, value);
break;
#if !CORE_CLR
#if !NETSTANDARD1_5
case OptionKeys.SslProtocols:
SslProtocols = OptionKeys.ParseSslProtocols(key, value);
break;
......
......@@ -111,7 +111,7 @@ internal static string TryGetAzureRoleInstanceIdNoThrow()
{
string roleInstanceId = null;
// TODO: CoreCLR port pending https://github.com/dotnet/coreclr/issues/919
#if !CORE_CLR
#if !NETSTANDARD1_5
try
{
Assembly asm = null;
......@@ -608,7 +608,7 @@ private static bool WaitAllIgnoreErrors(Task[] tasks, int timeout)
return false;
}
#if !CORE_CLR
#if FEATURE_THREADPOOL
private void LogLockedWithThreadPoolStats(TextWriter log, string message, out int busyWorkerCount)
{
busyWorkerCount = 0;
......@@ -650,7 +650,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
}
var watch = Stopwatch.StartNew();
#if !CORE_CLR
#if FEATURE_THREADPOOL
int busyWorkerCount;
LogLockedWithThreadPoolStats(log, "Awaiting task completion", out busyWorkerCount);
#endif
......@@ -660,7 +660,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var remaining = timeoutMilliseconds - checked((int)watch.ElapsedMilliseconds);
if (remaining <= 0)
{
#if !CORE_CLR
#if FEATURE_THREADPOOL
LogLockedWithThreadPoolStats(log, "Timeout before awaiting for tasks", out busyWorkerCount);
#endif
return false;
......@@ -669,7 +669,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var allTasks = Task.WhenAll(tasks).ObserveErrors();
var any = Task.WhenAny(allTasks, Task.Delay(remaining)).ObserveErrors();
bool all = await any.ForAwait() == allTasks;
#if !CORE_CLR
#if FEATURE_THREADPOOL
LogLockedWithThreadPoolStats(log, all ? "All tasks completed cleanly" : "Not all tasks completed cleanly", out busyWorkerCount);
#endif
return all;
......@@ -687,7 +687,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var remaining = timeoutMilliseconds - checked((int)watch.ElapsedMilliseconds);
if (remaining <= 0)
{
#if !CORE_CLR
#if FEATURE_THREADPOOL
LogLockedWithThreadPoolStats(log, "Timeout awaiting tasks", out busyWorkerCount);
#endif
return false;
......@@ -700,7 +700,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
{ }
}
}
#if !CORE_CLR
#if FEATURE_THREADPOOL
LogLockedWithThreadPoolStats(log, "Finished awaiting tasks", out busyWorkerCount);
#endif
return false;
......@@ -2068,13 +2068,14 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
{
add("Key-HashSlot", "keyHashSlot", message.GetHashSlot(this.ServerSelectionStrategy).ToString());
}
#if !CORE_CLR
#if FEATURE_THREADPOOL
string iocp, worker;
int busyWorkerCount = GetThreadPoolStats(out iocp, out worker);
add("ThreadPool-IO-Completion", "IOCP", iocp);
add("ThreadPool-Workers", "WORKER", worker);
data.Add(Tuple.Create("Busy-Workers", busyWorkerCount.ToString()));
#endif
#if FEATURE_PERFCOUNTER
if (IncludePerformanceCountersInExceptions)
{
add("Local-CPU", "Local-CPU", GetSystemCpuPercent());
......@@ -2115,7 +2116,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
}
}
#if !CORE_CLR
#if FEATURE_PERFCOUNTER
internal static string GetThreadPoolAndCPUSummary(bool includePerformanceCounters)
{
string iocp, worker;
......@@ -2133,7 +2134,8 @@ private static string GetSystemCpuPercent()
}
return "unavailable";
}
#endif
#if FEATURE_THREADPOOL
private static int GetThreadPoolStats(out string iocp, out string worker)
{
//BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
......
......@@ -285,7 +285,7 @@ public enum CompletionType
/// </summary>
Async = 2
}
#if !CORE_CLR
#if FEATURE_PERFCOUNTER
internal static class PerfCounterHelper
{
......@@ -332,8 +332,9 @@ public static bool TryGetSystemCPU(out float value)
return false;
}
}
internal static class CompletionTypeHelper
#endif
#if FEATURE_THREADPOOL
internal class CompletionTypeHelper
{
public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> beginAsync, AsyncCallback callback, CompletionType completionType)
{
......
......@@ -127,7 +127,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include
exceptionmessage.Append("; ").Append(innermostExceptionstring);
}
#if !CORE_CLR
#if FEATURE_PERFCOUNTER
if (includeDetail)
{
exceptionmessage.Append("; ").Append(ConnectionMultiplexer.GetThreadPoolAndCPUSummary(includePerformanceCounters));
......
......@@ -137,7 +137,7 @@ internal static void AuthenticateAsClient(this SslStream ssl, string host, SslPr
var certificateCollection = new X509CertificateCollection();
const bool checkCertRevocation = true;
#if CORE_CLR
#if NETSTANDARD1_5
ssl.AuthenticateAsClientAsync(host, certificateCollection, allowedProtocols.Value, checkCertRevocation)
.GetAwaiter().GetResult();
#else
......@@ -147,7 +147,7 @@ internal static void AuthenticateAsClient(this SslStream ssl, string host, SslPr
private static void AuthenticateAsClientUsingDefaultProtocols(SslStream ssl, string host)
{
#if CORE_CLR
#if NETSTANDARD1_5
ssl.AuthenticateAsClientAsync(host).GetAwaiter().GetResult();
#else
ssl.AuthenticateAsClient(host);
......
......@@ -32,7 +32,7 @@ public HashEntry(RedisValue name, RedisValue value)
/// <summary>
/// The name of the hash field
/// </summary>
#if !CORE_CLR
#if !NETSTANDARD1_5
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Name", false)]
......
......@@ -10,7 +10,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
#if CORE_CLR
#if NETSTANDARD1_5
using System.Threading.Tasks;
#endif
......@@ -26,7 +26,7 @@ internal sealed partial class PhysicalConnection : IDisposable, ISocketCallback
private static readonly byte[] Crlf = Encoding.ASCII.GetBytes("\r\n");
#if CORE_CLR
#if NETSTANDARD1_5
readonly Action<Task<int>> endRead;
private static Action<Task<int>> EndReadFactory(PhysicalConnection physical)
{
......@@ -110,7 +110,7 @@ public PhysicalConnection(PhysicalBridge bridge)
var endpoint = bridge.ServerEndPoint.EndPoint;
physicalName = connectionType + "#" + Interlocked.Increment(ref totalCount) + "@" + Format.ToString(endpoint);
this.Bridge = bridge;
#if CORE_CLR
#if NETSTANDARD1_5
endRead = EndReadFactory(this);
#endif
OnCreateEcho();
......@@ -147,7 +147,7 @@ public void Dispose()
if (outStream != null)
{
Multiplexer.Trace("Disconnecting...", physicalName);
#if !CORE_CLR
#if !NETSTANDARD1_5
try { outStream.Close(); } catch { }
#endif
try { outStream.Dispose(); } catch { }
......@@ -155,7 +155,7 @@ public void Dispose()
}
if (netStream != null)
{
#if !CORE_CLR
#if !NETSTANDARD1_5
try { netStream.Close(); } catch { }
#endif
try { netStream.Dispose(); } catch { }
......@@ -639,7 +639,7 @@ unsafe void WriteRaw(Stream stream, string value, int encodedLength)
}
else
{
#if !CORE_CLR
#if !NETSTANDARD1_5
fixed (char* c = value)
fixed (byte* b = outScratch)
{
......@@ -713,7 +713,7 @@ void BeginReading()
keepReading = false;
int space = EnsureSpaceAndComputeBytesToRead();
Multiplexer.Trace("Beginning async read...", physicalName);
#if CORE_CLR
#if NETSTANDARD1_5
var result = netStream.ReadAsync(ioBuffer, ioBufferBytes, space);
switch (result.Status)
{
......@@ -736,7 +736,7 @@ void BeginReading()
#endif
} while (keepReading);
}
#if CORE_CLR
#if NETSTANDARD1_5
catch (AggregateException ex)
{
throw ex.InnerException;
......@@ -835,7 +835,7 @@ SocketMode ISocketCallback.Connected(Stream stream, TextWriter log)
}
}
#if CORE_CLR
#if NETSTANDARD1_5
private bool EndReading(Task<int> result)
{
try
......
using System;
#if CORE_CLR
#if NETSTANDARD1_5
using System.Collections.Generic;
using System.Reflection;
#endif
......@@ -301,7 +301,7 @@ public int CompareTo(RedisValue other)
if (otherType == CompareType.Double) return thisDouble.CompareTo(otherDouble);
}
// otherwise, compare as strings
#if !CORE_CLR
#if !NETSTANDARD1_5
return StringComparer.InvariantCulture.Compare((string)this, (string)other);
#else
var compareInfo = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
......@@ -682,7 +682,7 @@ public bool TryParse(out double val)
internal static class ReflectionExtensions
{
#if CORE_CLR
#if NETSTANDARD1_5
internal static TypeCode GetTypeCode(this Type type)
{
if (type == null) return TypeCode.Empty;
......
......@@ -176,7 +176,7 @@ public virtual bool SetResult(PhysicalConnection connection, Message message, Ra
else
{
err = string.Format("Endpoint {0} serving hashslot {1} is not reachable at this point of time. Please check connectTimeout value. If it is low, try increasing it to give the ConnectionMultiplexer a chance to recover from the network disconnect. ", endpoint, hashSlot);
#if !CORE_CLR
#if FEATURE_PERFCOUNTER
err += ConnectionMultiplexer.GetThreadPoolAndCPUSummary(bridge.Multiplexer.IncludePerformanceCountersInExceptions);
#endif
}
......
......@@ -313,7 +313,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
LocalBuilder redisKeyLoc = null;
var loc = il.DeclareLocal(t);
il.Emit(OpCodes.Ldarg_0); // object
#if !CORE_CLR
#if !NETSTANDARD1_5
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......@@ -348,7 +348,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
{
il.Emit(OpCodes.Dup); // RedisKey[] RedisKey[]
il.Emit(OpCodes.Ldc_I4, i); // RedisKey[] RedisKey[] int
#if !CORE_CLR
#if !NETSTANDARD1_5
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......@@ -380,7 +380,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
{
il.Emit(OpCodes.Dup); // RedisKey[] RedisValue[] RedisValue[]
il.Emit(OpCodes.Ldc_I4, i); // RedisKey[] RedisValue[] RedisValue[] int
#if !CORE_CLR
#if !NETSTANDARD1_5
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......
......@@ -4,7 +4,7 @@
using System.Net;
using System.Net.Sockets;
using System.Threading;
#if CORE_CLR
#if NETSTANDARD1_5
using System.Runtime.InteropServices;
using System.Threading.Tasks;
#endif
......@@ -136,7 +136,7 @@ public SocketManager(string name, bool useHighPrioritySocketThreads)
// we need a dedicated writer, because when under heavy ambient load
// (a busy asp.net site, for example), workers are not reliable enough
#if !CORE_CLR
#if !NETSTANDARD1_5
Thread dedicatedWriter = new Thread(writeAllQueues, 32 * 1024); // don't need a huge stack;
dedicatedWriter.Priority = useHighPrioritySocketThreads ? ThreadPriority.AboveNormal : ThreadPriority.Normal;
#else
......@@ -190,7 +190,7 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
// A work-around for a Mono bug in BeginConnect(EndPoint endpoint, AsyncCallback callback, object state)
DnsEndPoint dnsEndpoint = (DnsEndPoint)endpoint;
#if CORE_CLR
#if !FEATURE_THREADPOOL
multiplexer.LogLocked(log, "BeginConnect: {0}", formattedEndpoint);
socket.ConnectAsync(dnsEndpoint.Host, dnsEndpoint.Port).ContinueWith(t =>
{
......@@ -214,7 +214,7 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
}
else
{
#if CORE_CLR
#if !FEATURE_THREADPOOL
multiplexer.LogLocked(log, "BeginConnect: {0}", formattedEndpoint);
socket.ConnectAsync(endpoint).ContinueWith(t =>
{
......@@ -254,7 +254,7 @@ internal void SetFastLoopbackOption(Socket socket)
// or will be subject to WFP filtering.
const int SIO_LOOPBACK_FAST_PATH = -1744830448;
#if !CORE_CLR
#if !NETSTANDARD1_5
// windows only
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
......@@ -322,7 +322,7 @@ private void EndConnectImpl(IAsyncResult ar, ConnectionMultiplexer multiplexer,
if (ignoreConnect) return;
var socket = tuple.Item1;
var callback = tuple.Item2;
#if CORE_CLR
#if NETSTANDARD1_5
multiplexer.Wait((Task)ar); // make it explode if invalid (note: already complete at this point)
#else
socket.EndConnect(ar);
......@@ -393,7 +393,7 @@ private void Shutdown(Socket socket)
{
OnShutdown(socket);
try { socket.Shutdown(SocketShutdown.Both); } catch { }
#if !CORE_CLR
#if !NETSTANDARD1_5
try { socket.Close(); } catch { }
#endif
try { socket.Dispose(); } catch { }
......
......@@ -37,7 +37,7 @@ public SortedSetEntry(RedisValue element, double score)
/// <summary>
/// The score against the element
/// </summary>
#if !CORE_CLR
#if !NETSTANDARD1_5
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Score", false)]
......@@ -46,7 +46,7 @@ public SortedSetEntry(RedisValue element, double score)
/// <summary>
/// The unique element stored in the sorted set
/// </summary>
#if !CORE_CLR
#if !NETSTANDARD1_5
[Browsable(false)]
#endif
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Element", false)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment