Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#254)
Instead of Task.FromResult(0)
This commit is contained in:
parent
295dab5d50
commit
7a37091d3b
|
|
@ -26,6 +26,7 @@ using System.Collections.Generic;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http.Features.Authentication;
|
using Microsoft.AspNetCore.Http.Features.Authentication;
|
||||||
|
using Microsoft.Extensions.Internal;
|
||||||
using Microsoft.Net.Http.Server;
|
using Microsoft.Net.Http.Server;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.WebListener
|
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)
|
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.
|
// A challenge was issued, it overrides any pre-set auth types.
|
||||||
_requestContext.Response.AuthenticationChallenges = _customChallenges;
|
_requestContext.Response.AuthenticationChallenges = _customChallenges;
|
||||||
return Task.FromResult(0);
|
return TaskCache.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetDescriptions(DescribeSchemesContext context)
|
public void GetDescriptions(DescribeSchemesContext context)
|
||||||
|
|
@ -123,13 +124,13 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
public Task SignInAsync(SignInContext context)
|
public Task SignInAsync(SignInContext context)
|
||||||
{
|
{
|
||||||
// Not supported. AuthenticationManager will throw if !Accepted.
|
// Not supported. AuthenticationManager will throw if !Accepted.
|
||||||
return Task.FromResult(0);
|
return TaskCache.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SignOutAsync(SignOutContext context)
|
public Task SignOutAsync(SignOutContext context)
|
||||||
{
|
{
|
||||||
// Not supported. AuthenticationManager will throw if !Accepted.
|
// Not supported. AuthenticationManager will throw if !Accepted.
|
||||||
return Task.FromResult(0);
|
return TaskCache.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDictionary<string, object> GetDescription(string authenticationScheme)
|
private IDictionary<string, object> GetDescription(string authenticationScheme)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.AspNetCore.Http.Features.Authentication;
|
using Microsoft.AspNetCore.Http.Features.Authentication;
|
||||||
|
using Microsoft.Extensions.Internal;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Microsoft.Net.Http.Server;
|
using Microsoft.Net.Http.Server;
|
||||||
|
|
||||||
|
|
@ -590,7 +591,7 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
{
|
{
|
||||||
if (_completed)
|
if (_completed)
|
||||||
{
|
{
|
||||||
return Helpers.CompletedTask;
|
return TaskCache.CompletedTask;
|
||||||
}
|
}
|
||||||
_completed = true;
|
_completed = true;
|
||||||
return NotifyOnCompletedAsync();
|
return NotifyOnCompletedAsync();
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ namespace Microsoft.AspNetCore.Server.WebListener
|
||||||
{
|
{
|
||||||
internal static class Helpers
|
internal static class Helpers
|
||||||
{
|
{
|
||||||
internal static Task CompletedTask { get; } = Task.FromResult(0);
|
|
||||||
|
|
||||||
internal static ConfiguredTaskAwaitable SupressContext(this Task task)
|
internal static ConfiguredTaskAwaitable SupressContext(this Task task)
|
||||||
{
|
{
|
||||||
return task.ConfigureAwait(continueOnCapturedContext: false);
|
return task.ConfigureAwait(continueOnCapturedContext: false);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNetCore.Hosting": "1.1.0-*",
|
"Microsoft.AspNetCore.Hosting": "1.1.0-*",
|
||||||
"Microsoft.Net.Http.Headers": "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": {
|
"buildOptions": {
|
||||||
"allowUnsafe": true,
|
"allowUnsafe": true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue