Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#955)
Instead of Task.FromResult(0)
This commit is contained in:
parent
2a03500ace
commit
e131ebae47
|
|
@ -9,6 +9,7 @@ using System.Security.Claims;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
{
|
||||
|
|
@ -263,7 +264,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
role.Name = roleName;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -354,7 +355,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(role));
|
||||
}
|
||||
role.NormalizedName = normalizedName;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using System.Security.Claims;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
||||
{
|
||||
|
|
@ -291,7 +292,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
protected Task SaveChanges(CancellationToken cancellationToken)
|
||||
{
|
||||
return AutoSaveChanges ? Context.SaveChangesAsync(cancellationToken) : Task.FromResult(0);
|
||||
return AutoSaveChanges ? Context.SaveChangesAsync(cancellationToken) : TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -344,7 +345,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.UserName = userName;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -380,7 +381,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.NormalizedUserName = normalizedName;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -541,7 +542,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.PasswordHash = passwordHash;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -933,7 +934,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.EmailConfirmed = confirmed;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -952,7 +953,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.Email = email;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1007,7 +1008,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.NormalizedEmail = normalizedEmail;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1062,7 +1063,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.LockoutEnd = lockoutEnd;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1099,7 +1100,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.AccessFailedCount = 0;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1154,7 +1155,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.LockoutEnabled = enabled;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1173,7 +1174,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.PhoneNumber = phoneNumber;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1229,7 +1230,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.PhoneNumberConfirmed = confirmed;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1248,7 +1249,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.SecurityStamp = stamp;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1285,7 +1286,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
|
|||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
user.TwoFactorEnabled = enabled;
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Identity": "1.1.0-*",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "1.1.0-*"
|
||||
"Microsoft.EntityFrameworkCore.Relational": "1.1.0-*",
|
||||
"Microsoft.Extensions.TaskCache.Sources": {
|
||||
"version": "1.1.0-*",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {},
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Authentication;
|
||||
using Microsoft.AspNetCore.Http.Features.Authentication;
|
||||
using Microsoft.Extensions.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
@ -662,7 +663,7 @@ namespace Microsoft.AspNetCore.Identity
|
|||
{
|
||||
return UserManager.ResetAccessFailedCountAsync(user);
|
||||
}
|
||||
return Task.FromResult(0);
|
||||
return TaskCache.CompletedTask;
|
||||
}
|
||||
|
||||
internal class TwoFactorAuthenticationInfo
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@
|
|||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.0-*",
|
||||
"Microsoft.AspNetCore.Cryptography.KeyDerivation": "1.1.0-*",
|
||||
"Microsoft.AspNetCore.Hosting.Abstractions": "1.1.0-*"
|
||||
"Microsoft.AspNetCore.Hosting.Abstractions": "1.1.0-*",
|
||||
"Microsoft.Extensions.TaskCache.Sources": {
|
||||
"version": "1.1.0-*",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": {},
|
||||
|
|
|
|||
Loading…
Reference in New Issue