Add missing doc comments

This commit is contained in:
Hao Kung 2016-07-05 14:14:42 -07:00
parent f73f668e2b
commit ec4c08d11a
15 changed files with 196 additions and 14 deletions

View File

@ -9,6 +9,9 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Contains extension methods to <see cref="IdentityBuilder"/> for adding entity framework stores.
/// </summary>
public static class IdentityEntityFrameworkBuilderExtensions
{
/// <summary>

View File

@ -32,11 +32,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// </summary>
public virtual string ClaimValue { get; set; }
/// <summary>
/// Constructs a new claim with the type and value.
/// </summary>
/// <returns></returns>
public virtual Claim ToClaim()
{
return new Claim(ClaimType, ClaimValue);
}
/// <summary>
/// Initializes by copying ClaimType and ClaimValue from the other claim.
/// </summary>
/// <param name="other">The claim to initialize from.</param>
public virtual void InitializeFromClaim(Claim other)
{
ClaimType = other?.Type;

View File

@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
public class RoleStore<TRole> : RoleStore<TRole, DbContext, string>
where TRole : IdentityRole<string>
{
/// <summary>
/// Constructs a new instance of <see cref="RoleStore{TRole}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public RoleStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
}
@ -31,6 +36,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
where TRole : IdentityRole<string>
where TContext : DbContext
{
/// <summary>
/// Constructs a new instance of <see cref="RoleStore{TRole, TContext}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
}
@ -47,10 +57,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
where TKey : IEquatable<TKey>
where TContext : DbContext
{
public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer)
{
}
/// <summary>
/// Constructs a new instance of <see cref="RoleStore{TRole, TContext, TKey}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
/// <summary>
/// Creates a entity representing a role claim.
/// </summary>
/// <param name="role">The associated role.</param>
/// <param name="claim">The associated claim.</param>
/// <returns>The role claim entity.</returns>
protected override IdentityRoleClaim<TKey> CreateRoleClaim(TRole role, Claim claim)
{
return new IdentityRoleClaim<TKey> { RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value };
@ -74,6 +93,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
where TUserRole : IdentityUserRole<TKey>
where TRoleClaim : IdentityRoleClaim<TKey>
{
/// <summary>
/// Constructs a new instance of <see cref="RoleStore{TRole, TContext, TKey, TUserRole, TRoleClaim}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public RoleStore(TContext context, IdentityErrorDescriber describer = null)
{
if (context == null)
@ -333,6 +357,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
return Task.FromResult(0);
}
/// <summary>
/// Throws if this class has been disposed.
/// </summary>
protected void ThrowIfDisposed()
{
if (_disposed)
@ -427,9 +454,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <summary>
/// Creates a entity representing a role claim.
/// </summary>
/// <param name="role"></param>
/// <param name="claim"></param>
/// <returns></returns>
/// <param name="role">The associated role.</param>
/// <param name="claim">The associated claim.</param>
/// <returns>The role claim entity.</returns>
protected abstract TRoleClaim CreateRoleClaim(TRole role, Claim claim);
}
}

View File

@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// </summary>
public class UserStore : UserStore<IdentityUser<string>>
{
/// <summary>
/// Constructs a new instance of <see cref="UserStore"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public UserStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
}
@ -29,6 +34,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
public class UserStore<TUser> : UserStore<TUser, IdentityRole, DbContext, string>
where TUser : IdentityUser<string>, new()
{
/// <summary>
/// Constructs a new instance of <see cref="UserStore{TUser}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public UserStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
}
@ -43,8 +53,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
where TRole : IdentityRole<string>
where TContext : DbContext
{
/// <summary>
/// Constructs a new instance of <see cref="UserStore{TUser, TRole, TContext}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public UserStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
}
/// <summary>
/// Represents a new instance of a persistence store for the specified user and role types.
/// </summary>
@ -58,8 +74,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
where TContext : DbContext
where TKey : IEquatable<TKey>
{
/// <summary>
/// Constructs a new instance of <see cref="UserStore{TUser, TRole, TContext, TKey}"/>.
/// </summary>
/// <param name="context">The <see cref="DbContext"/>.</param>
/// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param>
public UserStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }
/// <summary>
/// Called to create a new instance of a <see cref="IdentityUserRole{TKey}"/>.
/// </summary>
/// <param name="user">The associated user.</param>
/// <param name="role">The associated role.</param>
/// <returns></returns>
protected override IdentityUserRole<TKey> CreateUserRole(TUser user, TRole role)
{
return new IdentityUserRole<TKey>()
@ -69,6 +96,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
};
}
/// <summary>
/// Called to create a new instance of a <see cref="IdentityUserClaim{TKey}"/>.
/// </summary>
/// <param name="user">The associated user.</param>
/// <param name="claim">The associated claim.</param>
/// <returns></returns>
protected override IdentityUserClaim<TKey> CreateUserClaim(TUser user, Claim claim)
{
var userClaim = new IdentityUserClaim<TKey> { UserId = user.Id };
@ -76,6 +109,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
return userClaim;
}
/// <summary>
/// Called to create a new instance of a <see cref="IdentityUserLogin{TKey}"/>.
/// </summary>
/// <param name="user">The associated user.</param>
/// <param name="login">The sasociated login.</param>
/// <returns></returns>
protected override IdentityUserLogin<TKey> CreateUserLogin(TUser user, UserLoginInfo login)
{
return new IdentityUserLogin<TKey>
@ -87,6 +126,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
};
}
/// <summary>
/// Called to create a new instance of a <see cref="IdentityUserToken{TKey}"/>.
/// </summary>
/// <param name="user">The associated user.</param>
/// <param name="loginProvider">The associated login provider.</param>
/// <param name="name">The name of the user token.</param>
/// <param name="value">The value of the user token.</param>
/// <returns></returns>
protected override IdentityUserToken<TKey> CreateUserToken(TUser user, string loginProvider, string name, string value)
{
return new IdentityUserToken<TKey>
@ -603,6 +650,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
return false;
}
/// <summary>
/// Throws if this class has been disposed.
/// </summary>
protected void ThrowIfDisposed()
{
if (_disposed)
@ -1289,7 +1339,15 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
return UserTokens.SingleOrDefaultAsync(l => l.UserId.Equals(userId) && l.LoginProvider == loginProvider && l.Name == name, cancellationToken);
}
// <inheritdoc>
/// <summary>
/// Sets the token value for a particular user.
/// </summary>
/// <param name="user">The user.</param>
/// <param name="loginProvider">The authentication provider for the token.</param>
/// <param name="name">The name of the token.</param>
/// <param name="value">The value of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual async Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@ -1311,6 +1369,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
}
}
/// <summary>
/// Deletes a token for a user.
/// </summary>
/// <param name="user">The user.</param>
/// <param name="loginProvider">The authentication provider for the token.</param>
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@ -1328,6 +1394,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
}
}
/// <summary>
/// Returns the token value.
/// </summary>
/// <param name="user">The user.</param>
/// <param name="loginProvider">The authentication provider for the token.</param>
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();

View File

@ -4,9 +4,6 @@
"buildOptions": {
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk",
"nowarn": [
"CS1591"
],
"xmlDoc": true
},
"packOptions": {

View File

@ -31,6 +31,9 @@ namespace Microsoft.AspNetCore.Identity
/// <value>The <see cref="ClaimsPrincipal"/> associated with this login.</value>
public ClaimsPrincipal Principal { get; set; }
/// <summary>
/// The <see cref="AuthenticationToken"/>s associated with this login.
/// </summary>
public IEnumerable<AuthenticationToken> AuthenticationTokens { get; set; }
}
}

View File

@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.Identity
/// <param name="loginProvider">The authentication provider for the token.</param>
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken);
/// <summary>

View File

@ -19,6 +19,9 @@ namespace Microsoft.AspNetCore.Identity
private static readonly string DefaultTwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe";
private static readonly string DefaultTwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId";
/// <summary>
/// Constructs a new instance of <see cref="IdentityCookieOptions"/>.
/// </summary>
public IdentityCookieOptions()
{
// Configure all of the cookie middlewares
@ -58,9 +61,24 @@ namespace Microsoft.AspNetCore.Identity
};
}
/// <summary>
/// The options for the application cookie.
/// </summary>
public CookieAuthenticationOptions ApplicationCookie { get; set; }
/// <summary>
/// The options for the external cookie.
/// </summary>
public CookieAuthenticationOptions ExternalCookie { get; set; }
/// <summary>
/// The options for the two factor remember me cookie.
/// </summary>
public CookieAuthenticationOptions TwoFactorRememberMeCookie { get; set; }
/// <summary>
/// The options for the two factor user id cookie.
/// </summary>
public CookieAuthenticationOptions TwoFactorUserIdCookie { get; set; }
/// <summary>

View File

@ -455,7 +455,10 @@ namespace Microsoft.AspNetCore.Identity
}
return cast;
}
/// <summary>
/// Throws if this class has been disposed.
/// </summary>
protected void ThrowIfDisposed()
{
if (_disposed)

View File

@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity
private readonly SignInManager<TUser> _signInManager;
private readonly IdentityOptions _options;
/// <summary>
/// Creates a new instance of <see cref="SecurityStampValidator{TUser}"/>.
/// </summary>
/// <param name="options">Used to access the <see cref="IdentityOptions"/>.</param>
/// <param name="signInManager">The <see cref="SignInManager{TUser}"/>.</param>
public SecurityStampValidator(IOptions<IdentityOptions> options, SignInManager<TUser> signInManager)
{
if (options == null)

View File

@ -69,7 +69,12 @@ namespace Microsoft.AspNetCore.Identity
/// The <see cref="ILogger"/> used to log messages from the manager.
/// </value>
protected internal virtual ILogger Logger { get; set; }
/// <summary>
/// The <see cref="UserManager{TUser}"/> used.
/// </summary>
protected internal UserManager<TUser> UserManager { get; set; }
internal IUserClaimsPrincipalFactory<TUser> ClaimsFactory { get; set; }
internal IdentityOptions Options { get; set; }

View File

@ -6,10 +6,24 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Identity
{
/// <summary>
/// Options for user tokens.
/// </summary>
public class TokenOptions
{
/// <summary>
/// Default token provider name used by email confirmation, password reset, and change email.
/// </summary>
public static readonly string DefaultProvider = "Default";
/// <summary>
/// Default token provider name used by the <see cref="EmailTokenProvider{TUser}"/>.
/// </summary>
public static readonly string DefaultEmailProvider = "Email";
/// <summary>
/// Default token provider name used by the <see cref="PhoneNumberTokenProvider{TUser}"/>.
/// </summary>
public static readonly string DefaultPhoneProvider = "Phone";
/// <summary>

View File

@ -5,13 +5,23 @@ using System;
namespace Microsoft.AspNetCore.Identity
{
/// <summary>
/// Used to represents a token provider in <see cref="TokenOptions"/>'s TokenMap.
/// </summary>
public class TokenProviderDescriptor
{
/// <summary>
/// Initializes a new instance of the <see cref="TokenProviderDescriptor"/> class.
/// </summary>
/// <param name="type">The concrete type for this token provider.</param>
public TokenProviderDescriptor(Type type)
{
ProviderType = type;
}
/// <summary>
/// The type that will be used for this token provider.
/// </summary>
public Type ProviderType { get; }
}
}

View File

@ -23,7 +23,14 @@ namespace Microsoft.AspNetCore.Identity
/// <typeparam name="TUser">The type encapsulating a user.</typeparam>
public class UserManager<TUser> : IDisposable where TUser : class
{
/// <summary>
/// The data protection purpose used for the reset password related methods.
/// </summary>
protected const string ResetPasswordTokenPurpose = "ResetPassword";
/// <summary>
/// The data protection purpose used for the email confirmation related methods.
/// </summary>
protected const string ConfirmEmailTokenPurpose = "EmailConfirmation";
private readonly Dictionary<string, IUserTwoFactorTokenProvider<TUser>> _tokenProviders =
@ -344,6 +351,13 @@ namespace Microsoft.AspNetCore.Identity
return principal.FindFirstValue(Options.ClaimsIdentity.UserIdClaimType);
}
/// <summary>
/// Returns the user corresponding to the IdentityOptions.ClaimsIdentity.UserIdClaimType claim in
/// the principal or null.
/// </summary>
/// <param name="principal">The principal which contains the user id claim.</param>
/// <returns>The user corresponding to the IdentityOptions.ClaimsIdentity.UserIdClaimType claim in
/// the principal or null</returns>
public virtual Task<TUser> GetUserAsync(ClaimsPrincipal principal)
{
if (principal == null)
@ -2265,6 +2279,9 @@ namespace Microsoft.AspNetCore.Identity
return cast;
}
/// <summary>
/// Throws if this class has been disposed.
/// </summary>
protected void ThrowIfDisposed()
{
if (_disposed)

View File

@ -4,9 +4,6 @@
"buildOptions": {
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk",
"nowarn": [
"CS1591"
],
"xmlDoc": true
},
"packOptions": {