#59 - Use Task.GetAwaiter().GetResult() instead of Task.Result.
This commit is contained in:
parent
e315a545cb
commit
6965a66f18
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Security.Cookies
|
||||||
|
|
||||||
protected override AuthenticationTicket AuthenticateCore()
|
protected override AuthenticationTicket AuthenticateCore()
|
||||||
{
|
{
|
||||||
return AuthenticateCoreAsync().Result;
|
return AuthenticateCoreAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Security.Cookies
|
||||||
|
|
||||||
protected override void ApplyResponseGrant()
|
protected override void ApplyResponseGrant()
|
||||||
{
|
{
|
||||||
ApplyResponseGrantAsync().Wait();
|
ApplyResponseGrantAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task ApplyResponseGrantAsync()
|
protected override async Task ApplyResponseGrantAsync()
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Security.OAuth
|
||||||
|
|
||||||
protected override AuthenticationTicket AuthenticateCore()
|
protected override AuthenticationTicket AuthenticateCore()
|
||||||
{
|
{
|
||||||
return AuthenticateCoreAsync().Result;
|
return AuthenticateCoreAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Security.OAuth
|
||||||
|
|
||||||
protected override AuthenticationTicket AuthenticateCore()
|
protected override AuthenticationTicket AuthenticateCore()
|
||||||
{
|
{
|
||||||
return AuthenticateCoreAsync().Result;
|
return AuthenticateCoreAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Security.Twitter
|
||||||
|
|
||||||
protected override AuthenticationTicket AuthenticateCore()
|
protected override AuthenticationTicket AuthenticateCore()
|
||||||
{
|
{
|
||||||
return AuthenticateCoreAsync().Result;
|
return AuthenticateCoreAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Security.Twitter
|
||||||
}
|
}
|
||||||
protected override void ApplyResponseChallenge()
|
protected override void ApplyResponseChallenge()
|
||||||
{
|
{
|
||||||
ApplyResponseChallengeAsync().Wait();
|
ApplyResponseChallengeAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task ApplyResponseChallengeAsync()
|
protected override async Task ApplyResponseChallengeAsync()
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Security
|
||||||
|
|
||||||
public bool Authorize(IEnumerable<Claim> claims, ClaimsPrincipal user, object resource)
|
public bool Authorize(IEnumerable<Claim> claims, ClaimsPrincipal user, object resource)
|
||||||
{
|
{
|
||||||
return AuthorizeAsync(claims, user, resource).Result;
|
return AuthorizeAsync(claims, user, resource).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ClaimsMatch([NotNull] IEnumerable<Claim> x, [NotNull] IEnumerable<Claim> y)
|
private bool ClaimsMatch([NotNull] IEnumerable<Claim> x, [NotNull] IEnumerable<Claim> y)
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ namespace Microsoft.AspNet.Security.Infrastructure
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
return Task.FromResult(AuthenticateCore());
|
return Task.FromResult(AuthenticateCore());
|
||||||
}).Result;
|
}).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AuthenticationTicket AuthenticateCore();
|
protected abstract AuthenticationTicket AuthenticateCore();
|
||||||
|
|
@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Security.Infrastructure
|
||||||
{
|
{
|
||||||
ApplyResponseCore();
|
ApplyResponseCore();
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}).Wait(); // Block if the async version is in progress.
|
}).GetAwaiter().GetResult(); // Block if the async version is in progress.
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ApplyResponseCore()
|
protected virtual void ApplyResponseCore()
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ namespace Microsoft.AspNet.Security.Test
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
// Assert
|
// Assert
|
||||||
Exception ex = Assert.Throws<AggregateException>(() => authorizationService.Authorize(Enumerable.Empty<Claim>(), null));
|
Exception ex = Assert.Throws<InvalidOperationException>(() => authorizationService.Authorize(Enumerable.Empty<Claim>(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue