Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#254)

Instead of Task.FromResult(0)
This commit is contained in:
Pavel Krymets 2016-09-08 10:02:07 -07:00 committed by GitHub
parent 295dab5d50
commit 7a37091d3b
4 changed files with 12 additions and 8 deletions

View File

@ -26,6 +26,7 @@ using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.Extensions.Internal;
using Microsoft.Net.Http.Server;
namespace Microsoft.AspNetCore.Server.WebListener
@ -63,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
}
}
}
return Task.FromResult(0);
return TaskCache.CompletedTask;
}
public Task ChallengeAsync(ChallengeContext context)
@ -108,7 +109,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
}
// A challenge was issued, it overrides any pre-set auth types.
_requestContext.Response.AuthenticationChallenges = _customChallenges;
return Task.FromResult(0);
return TaskCache.CompletedTask;
}
public void GetDescriptions(DescribeSchemesContext context)
@ -123,13 +124,13 @@ namespace Microsoft.AspNetCore.Server.WebListener
public Task SignInAsync(SignInContext context)
{
// Not supported. AuthenticationManager will throw if !Accepted.
return Task.FromResult(0);
return TaskCache.CompletedTask;
}
public Task SignOutAsync(SignOutContext context)
{
// Not supported. AuthenticationManager will throw if !Accepted.
return Task.FromResult(0);
return TaskCache.CompletedTask;
}
private IDictionary<string, object> GetDescription(string authenticationScheme)

View File

@ -28,6 +28,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.Extensions.Internal;
using Microsoft.Net.Http.Headers;
using Microsoft.Net.Http.Server;
@ -590,7 +591,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
{
if (_completed)
{
return Helpers.CompletedTask;
return TaskCache.CompletedTask;
}
_completed = true;
return NotifyOnCompletedAsync();

View File

@ -28,8 +28,6 @@ namespace Microsoft.AspNetCore.Server.WebListener
{
internal static class Helpers
{
internal static Task CompletedTask { get; } = Task.FromResult(0);
internal static ConfiguredTaskAwaitable SupressContext(this Task task)
{
return task.ConfigureAwait(continueOnCapturedContext: false);

View File

@ -4,7 +4,11 @@
"dependencies": {
"Microsoft.AspNetCore.Hosting": "1.1.0-*",
"Microsoft.Net.Http.Headers": "1.1.0-*",
"Microsoft.Net.Http.Server": "0.2.0-*"
"Microsoft.Net.Http.Server": "0.2.0-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
}
},
"buildOptions": {
"allowUnsafe": true,