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