Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#1089)
Instead of Task.FromResult(0)
This commit is contained in:
parent
5b2065230d
commit
c777a9efea
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
||||
{
|
||||
|
|
@ -55,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
|
|||
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
return TaskCache<int>.DefaultCompletedTask;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Server.KestrelTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: AssemblyMetadata("Serviceable", "True")]
|
||||
[assembly: NeutralResourcesLanguage("en-us")]
|
||||
[assembly: AssemblyCompany("Microsoft Corporation.")]
|
||||
|
|
|
|||
|
|
@ -19,7 +19,11 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*"
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*",
|
||||
"Microsoft.Extensions.TaskCache.Sources": {
|
||||
"version": "1.1.0-*",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {},
|
||||
|
|
|
|||
|
|
@ -6,18 +6,16 @@ using System.IO;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Filter.Internal
|
||||
{
|
||||
public class LibuvStream : Stream
|
||||
{
|
||||
private readonly static Task<int> _initialCachedTask = Task.FromResult(0);
|
||||
|
||||
private readonly SocketInput _input;
|
||||
private readonly ISocketOutput _output;
|
||||
|
||||
private Task<int> _cachedTask = _initialCachedTask;
|
||||
private Task<int> _cachedTask = TaskCache<int>.DefaultCompletedTask;
|
||||
|
||||
public LibuvStream(SocketInput input, ISocketOutput output)
|
||||
{
|
||||
|
|
@ -125,7 +123,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Filter.Internal
|
|||
public override Task FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// No-op since writes are immediate.
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
private ValueTask<int> ReadAsync(ArraySegment<byte> buffer)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Filter
|
||||
{
|
||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Filter
|
|||
{
|
||||
public Task OnConnectionAsync(ConnectionFilterContext context)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
|
|
@ -338,7 +339,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
_requestProcessingStopping = true;
|
||||
}
|
||||
return _requestProcessingTask ?? TaskUtilities.CompletedTask;
|
||||
return _requestProcessingTask ?? TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -500,7 +501,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
if (data.Count == 0)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
return WriteChunkedAsync(data, cancellationToken);
|
||||
}
|
||||
|
|
@ -569,7 +570,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
if (HasResponseStarted)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
if (_onStarting != null)
|
||||
|
|
@ -583,7 +584,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
|
||||
ProduceStart(appCompleted: false);
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task ProduceStartAndFireOnStartingAwaited()
|
||||
|
|
@ -624,7 +625,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
return ProduceEnd();
|
||||
}
|
||||
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
protected Task ProduceEnd()
|
||||
|
|
@ -635,7 +636,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
// We can no longer change the response, so we simply close the connection.
|
||||
_requestProcessingStopping = true;
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
if (_requestRejected)
|
||||
|
|
@ -697,7 +698,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
ConnectionControl.End(ProduceEndType.ConnectionKeepAlive);
|
||||
}
|
||||
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task WriteAutoChunkSuffixAwaited()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||
{
|
||||
|
|
@ -54,7 +55,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
public override Task FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// No-op.
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
else if (result.Result == 0)
|
||||
{
|
||||
// Completed Task, end of stream
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
} while (true);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||
|
|
@ -98,7 +99,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
{
|
||||
_log.ConnectionDisconnectedWrite(_connectionId, buffer.Count, _lastWriteError);
|
||||
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
if (buffer.Count > 0)
|
||||
|
|
@ -106,7 +107,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
var tail = ProducingStart();
|
||||
if (tail.IsDefault)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
if (chunk)
|
||||
|
|
@ -201,7 +202,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
|
||||
// Return TaskCompletionSource's Task if set, otherwise completed Task
|
||||
return tcs?.Task ?? TaskUtilities.CompletedTask;
|
||||
return tcs?.Task ?? TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
public void End(ProduceEndType endType)
|
||||
|
|
@ -523,7 +524,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else if (_cancelled)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
return WriteAsync(buffer, cancellationToken, chunk);
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
{
|
||||
public static class TaskUtilities
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
public static Task CompletedTask = Task.CompletedTask;
|
||||
#else
|
||||
public static Task CompletedTask = Task.FromResult<object>(null);
|
||||
#endif
|
||||
public static Task<int> ZeroTask = Task.FromResult(0);
|
||||
|
||||
public static Task GetCancelledTask(CancellationToken cancellationToken)
|
||||
{
|
||||
#if NETSTANDARD1_3
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@
|
|||
"System.Threading.Tasks.Extensions": "4.0.0-*",
|
||||
"Libuv": "1.9.0-*",
|
||||
"Microsoft.AspNetCore.Hosting": "1.1.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.1.0-*"
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.1.0-*",
|
||||
"Microsoft.Extensions.TaskCache.Sources": {
|
||||
"version": "1.1.0-*",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
await context.Response.WriteAsync("hello, world");
|
||||
await context.Response.Body.FlushAsync();
|
||||
ex = Assert.Throws<InvalidOperationException>(() => context.Response.OnStarting(_ => TaskUtilities.CompletedTask, null));
|
||||
ex = Assert.Throws<InvalidOperationException>(() => context.Response.OnStarting(_ => TaskCache.CompletedTask, null));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
[InlineData("post= / HTTP/1.0\r\n")]
|
||||
public async Task TestInvalidRequestLines(string request)
|
||||
{
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
[InlineData("Header-1: value1\r\nHeader-2\t: value2\r\n\r\n")]
|
||||
public async Task TestInvalidHeaders(string rawHeaders)
|
||||
{
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
|
||||
using Microsoft.AspNetCore.Server.KestrelTests.TestHelpers;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
var context = new ListenerContext(new TestServiceContext())
|
||||
{
|
||||
FrameFactory = connectionContext => new Frame<HttpContext>(
|
||||
new DummyApplication(httpContext => TaskUtilities.CompletedTask), connectionContext),
|
||||
new DummyApplication(httpContext => TaskCache.CompletedTask), connectionContext),
|
||||
ServerAddress = ServerAddress.FromUrl("http://127.0.0.1:0"),
|
||||
Thread = engine.Threads[0]
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
ServerOptions = { AddServerHeader = true }
|
||||
};
|
||||
|
||||
using (var server = new TestServer(ctx => TaskUtilities.CompletedTask, testContext))
|
||||
using (var server = new TestServer(ctx => TaskCache.CompletedTask, testContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Internal;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
|
|
@ -1084,7 +1085,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Abort();
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, testContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1121,7 +1122,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
Assert.Same(originalRequestHeaders, requestFeature.Headers);
|
||||
}
|
||||
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, testContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1168,7 +1169,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
Assert.Same(originalResponseHeaders, responseFeature.Headers);
|
||||
}
|
||||
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, testContext))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1234,12 +1235,12 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
context.Response.OnStarting(_ =>
|
||||
{
|
||||
callOrder.Push(1);
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnStarting(_ =>
|
||||
{
|
||||
callOrder.Push(2);
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, null);
|
||||
|
||||
context.Response.ContentLength = response.Length;
|
||||
|
|
@ -1278,12 +1279,12 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
context.Response.OnCompleted(_ =>
|
||||
{
|
||||
callOrder.Push(1);
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnCompleted(_ =>
|
||||
{
|
||||
callOrder.Push(2);
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}, null);
|
||||
|
||||
context.Response.ContentLength = response.Length;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.KestrelTests.TestHelpers;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
|
|
@ -629,7 +630,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
|
||||
// Act/Assert
|
||||
Assert.True(frame.HasResponseStarted);
|
||||
Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)frame).OnStarting(_ => TaskUtilities.CompletedTask, null));
|
||||
Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)frame).OnStarting(_ => TaskCache.CompletedTask, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Filter;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -113,7 +114,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
new NoOpConnectionFilter())
|
||||
);
|
||||
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask, serviceContext, _serverAddress))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, _serverAddress))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -231,7 +232,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
new NoOpConnectionFilter())
|
||||
);
|
||||
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask, serviceContext, _serverAddress))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, _serverAddress))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -258,7 +259,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
new NoOpConnectionFilter())
|
||||
);
|
||||
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask, serviceContext, _serverAddress))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, _serverAddress))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
@ -283,7 +284,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
new NoOpConnectionFilter())
|
||||
);
|
||||
|
||||
using (var server = new TestServer(context => TaskUtilities.CompletedTask, serviceContext, _serverAddress))
|
||||
using (var server = new TestServer(context => TaskCache.CompletedTask, serviceContext, _serverAddress))
|
||||
{
|
||||
using (var client = new TcpClient())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ using System;
|
|||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Server.Kestrel;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
|
||||
private static void StartDummyApplication(IServer server)
|
||||
{
|
||||
server.Start(new DummyApplication(context => TaskUtilities.CompletedTask));
|
||||
server.Start(new DummyApplication(context => TaskCache.CompletedTask));
|
||||
}
|
||||
|
||||
private class TestLoggerFactory : ILoggerFactory
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
|||
|
||||
public Task FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
public void ProduceContinue()
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
|||
|
||||
public Task WriteAsync(ArraySegment<byte> data, CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
||||
{
|
||||
|
|
@ -26,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
|||
|
||||
public Task WriteAsync(ArraySegment<byte> buffer, bool chunk = false, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Filter;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Filter.Internal;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
{
|
||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
public Task OnConnectionAsync(ConnectionFilterContext context)
|
||||
{
|
||||
context.Connection = new LoggingStream(context.Connection, new TestApplicationErrorLogger());
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.KestrelTests.TestHelpers;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||
{
|
||||
|
|
@ -84,7 +85,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
|
||||
Task IFrameControl.WriteAsync(ArraySegment<byte> data, CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
void IFrameControl.Flush()
|
||||
|
|
@ -93,7 +94,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
|
||||
Task IFrameControl.FlushAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return TaskUtilities.CompletedTask;
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
Loading…
Reference in New Issue