From ec4c08d11a00ec9b4dd8c22ef13a4950cb70901e Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 5 Jul 2016 14:14:42 -0700 Subject: [PATCH] Add missing doc comments --- ...dentityEntityFrameworkBuilderExtensions.cs | 3 + .../IdentityRoleClaim.cs | 8 ++ .../RoleStore.cs | 39 ++++++++-- .../UserStore.cs | 76 ++++++++++++++++++- .../project.json | 3 - .../ExternalLoginInfo.cs | 3 + .../IUserAuthenticationTokenStore.cs | 1 + .../IdentityCookieOptions.cs | 18 +++++ .../RoleManager.cs | 5 +- .../SecurityStampValidator.cs | 5 ++ .../SignInManager.cs | 5 ++ .../TokenOptions.cs | 14 ++++ .../TokenProviderDescriptor.cs | 10 +++ .../UserManager.cs | 17 +++++ .../project.json | 3 - 15 files changed, 196 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs index 8a5476d305..6d195c903e 100644 --- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityEntityFrameworkBuilderExtensions.cs @@ -9,6 +9,9 @@ using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { + /// + /// Contains extension methods to for adding entity framework stores. + /// public static class IdentityEntityFrameworkBuilderExtensions { /// diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityRoleClaim.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityRoleClaim.cs index d9a6672b0b..1a4c55e996 100644 --- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityRoleClaim.cs +++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityRoleClaim.cs @@ -32,11 +32,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore /// public virtual string ClaimValue { get; set; } + /// + /// Constructs a new claim with the type and value. + /// + /// public virtual Claim ToClaim() { return new Claim(ClaimType, ClaimValue); } + /// + /// Initializes by copying ClaimType and ClaimValue from the other claim. + /// + /// The claim to initialize from. public virtual void InitializeFromClaim(Claim other) { ClaimType = other?.Type; diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/RoleStore.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/RoleStore.cs index 60a40af476..f913931656 100644 --- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/RoleStore.cs +++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/RoleStore.cs @@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore public class RoleStore : RoleStore where TRole : IdentityRole { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public RoleStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } @@ -31,6 +36,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore where TRole : IdentityRole where TContext : DbContext { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } @@ -47,10 +57,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore where TKey : IEquatable where TContext : DbContext { - public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) - { - } + /// + /// Constructs a new instance of . + /// + /// The . + /// The . + public RoleStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } + /// + /// Creates a entity representing a role claim. + /// + /// The associated role. + /// The associated claim. + /// The role claim entity. protected override IdentityRoleClaim CreateRoleClaim(TRole role, Claim claim) { return new IdentityRoleClaim { RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value }; @@ -74,6 +93,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore where TUserRole : IdentityUserRole where TRoleClaim : IdentityRoleClaim { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public RoleStore(TContext context, IdentityErrorDescriber describer = null) { if (context == null) @@ -333,6 +357,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore return Task.FromResult(0); } + /// + /// Throws if this class has been disposed. + /// protected void ThrowIfDisposed() { if (_disposed) @@ -427,9 +454,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore /// /// Creates a entity representing a role claim. /// - /// - /// - /// + /// The associated role. + /// The associated claim. + /// The role claim entity. protected abstract TRoleClaim CreateRoleClaim(TRole role, Claim claim); } } diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/UserStore.cs b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/UserStore.cs index 1300eac368..151e462e1a 100644 --- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/UserStore.cs +++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/UserStore.cs @@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore /// public class UserStore : UserStore> { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public UserStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } @@ -29,6 +34,11 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore public class UserStore : UserStore where TUser : IdentityUser, new() { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public UserStore(DbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } @@ -43,8 +53,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore where TRole : IdentityRole where TContext : DbContext { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public UserStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } } + /// /// Represents a new instance of a persistence store for the specified user and role types. /// @@ -58,8 +74,19 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore where TContext : DbContext where TKey : IEquatable { + /// + /// Constructs a new instance of . + /// + /// The . + /// The . public UserStore(TContext context, IdentityErrorDescriber describer = null) : base(context, describer) { } + /// + /// Called to create a new instance of a . + /// + /// The associated user. + /// The associated role. + /// protected override IdentityUserRole CreateUserRole(TUser user, TRole role) { return new IdentityUserRole() @@ -69,6 +96,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore }; } + /// + /// Called to create a new instance of a . + /// + /// The associated user. + /// The associated claim. + /// protected override IdentityUserClaim CreateUserClaim(TUser user, Claim claim) { var userClaim = new IdentityUserClaim { UserId = user.Id }; @@ -76,6 +109,12 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore return userClaim; } + /// + /// Called to create a new instance of a . + /// + /// The associated user. + /// The sasociated login. + /// protected override IdentityUserLogin CreateUserLogin(TUser user, UserLoginInfo login) { return new IdentityUserLogin @@ -87,6 +126,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore }; } + /// + /// Called to create a new instance of a . + /// + /// The associated user. + /// The associated login provider. + /// The name of the user token. + /// The value of the user token. + /// protected override IdentityUserToken CreateUserToken(TUser user, string loginProvider, string name, string value) { return new IdentityUserToken @@ -603,6 +650,9 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore return false; } + /// + /// Throws if this class has been disposed. + /// 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); } - // + /// + /// Sets the token value for a particular user. + /// + /// The user. + /// The authentication provider for the token. + /// The name of the token. + /// The value of the token. + /// The used to propagate notifications that the operation should be canceled. + /// The that represents the asynchronous operation. 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 } } + /// + /// Deletes a token for a user. + /// + /// The user. + /// The authentication provider for the token. + /// The name of the token. + /// The used to propagate notifications that the operation should be canceled. + /// The that represents the asynchronous operation. public async Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -1328,6 +1394,14 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore } } + /// + /// Returns the token value. + /// + /// The user. + /// The authentication provider for the token. + /// The name of the token. + /// The used to propagate notifications that the operation should be canceled. + /// The that represents the asynchronous operation. public async Task GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/project.json b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/project.json index 4e7e32ac8b..966caf36f3 100644 --- a/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/project.json +++ b/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/project.json @@ -4,9 +4,6 @@ "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], "xmlDoc": true }, "packOptions": { diff --git a/src/Microsoft.AspNetCore.Identity/ExternalLoginInfo.cs b/src/Microsoft.AspNetCore.Identity/ExternalLoginInfo.cs index 682e97f367..e7305324f9 100644 --- a/src/Microsoft.AspNetCore.Identity/ExternalLoginInfo.cs +++ b/src/Microsoft.AspNetCore.Identity/ExternalLoginInfo.cs @@ -31,6 +31,9 @@ namespace Microsoft.AspNetCore.Identity /// The associated with this login. public ClaimsPrincipal Principal { get; set; } + /// + /// The s associated with this login. + /// public IEnumerable AuthenticationTokens { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Identity/IUserAuthenticationTokenStore.cs b/src/Microsoft.AspNetCore.Identity/IUserAuthenticationTokenStore.cs index 28ddee9dcc..9023bf6037 100644 --- a/src/Microsoft.AspNetCore.Identity/IUserAuthenticationTokenStore.cs +++ b/src/Microsoft.AspNetCore.Identity/IUserAuthenticationTokenStore.cs @@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.Identity /// The authentication provider for the token. /// The name of the token. /// The used to propagate notifications that the operation should be canceled. + /// The that represents the asynchronous operation. Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken); /// diff --git a/src/Microsoft.AspNetCore.Identity/IdentityCookieOptions.cs b/src/Microsoft.AspNetCore.Identity/IdentityCookieOptions.cs index fc78fcf301..4d694c7009 100644 --- a/src/Microsoft.AspNetCore.Identity/IdentityCookieOptions.cs +++ b/src/Microsoft.AspNetCore.Identity/IdentityCookieOptions.cs @@ -19,6 +19,9 @@ namespace Microsoft.AspNetCore.Identity private static readonly string DefaultTwoFactorRememberMeScheme = CookiePrefix + ".TwoFactorRememberMe"; private static readonly string DefaultTwoFactorUserIdScheme = CookiePrefix + ".TwoFactorUserId"; + /// + /// Constructs a new instance of . + /// public IdentityCookieOptions() { // Configure all of the cookie middlewares @@ -58,9 +61,24 @@ namespace Microsoft.AspNetCore.Identity }; } + /// + /// The options for the application cookie. + /// public CookieAuthenticationOptions ApplicationCookie { get; set; } + + /// + /// The options for the external cookie. + /// public CookieAuthenticationOptions ExternalCookie { get; set; } + + /// + /// The options for the two factor remember me cookie. + /// public CookieAuthenticationOptions TwoFactorRememberMeCookie { get; set; } + + /// + /// The options for the two factor user id cookie. + /// public CookieAuthenticationOptions TwoFactorUserIdCookie { get; set; } /// diff --git a/src/Microsoft.AspNetCore.Identity/RoleManager.cs b/src/Microsoft.AspNetCore.Identity/RoleManager.cs index 70080106ca..38be51f521 100644 --- a/src/Microsoft.AspNetCore.Identity/RoleManager.cs +++ b/src/Microsoft.AspNetCore.Identity/RoleManager.cs @@ -455,7 +455,10 @@ namespace Microsoft.AspNetCore.Identity } return cast; } - + + /// + /// Throws if this class has been disposed. + /// protected void ThrowIfDisposed() { if (_disposed) diff --git a/src/Microsoft.AspNetCore.Identity/SecurityStampValidator.cs b/src/Microsoft.AspNetCore.Identity/SecurityStampValidator.cs index 314bc64de3..490a1b68cf 100644 --- a/src/Microsoft.AspNetCore.Identity/SecurityStampValidator.cs +++ b/src/Microsoft.AspNetCore.Identity/SecurityStampValidator.cs @@ -19,6 +19,11 @@ namespace Microsoft.AspNetCore.Identity private readonly SignInManager _signInManager; private readonly IdentityOptions _options; + /// + /// Creates a new instance of . + /// + /// Used to access the . + /// The . public SecurityStampValidator(IOptions options, SignInManager signInManager) { if (options == null) diff --git a/src/Microsoft.AspNetCore.Identity/SignInManager.cs b/src/Microsoft.AspNetCore.Identity/SignInManager.cs index 37b129adbf..ed7a802947 100644 --- a/src/Microsoft.AspNetCore.Identity/SignInManager.cs +++ b/src/Microsoft.AspNetCore.Identity/SignInManager.cs @@ -69,7 +69,12 @@ namespace Microsoft.AspNetCore.Identity /// The used to log messages from the manager. /// protected internal virtual ILogger Logger { get; set; } + + /// + /// The used. + /// protected internal UserManager UserManager { get; set; } + internal IUserClaimsPrincipalFactory ClaimsFactory { get; set; } internal IdentityOptions Options { get; set; } diff --git a/src/Microsoft.AspNetCore.Identity/TokenOptions.cs b/src/Microsoft.AspNetCore.Identity/TokenOptions.cs index 74c10d1e4d..8707826f87 100644 --- a/src/Microsoft.AspNetCore.Identity/TokenOptions.cs +++ b/src/Microsoft.AspNetCore.Identity/TokenOptions.cs @@ -6,10 +6,24 @@ using System.Collections.Generic; namespace Microsoft.AspNetCore.Identity { + /// + /// Options for user tokens. + /// public class TokenOptions { + /// + /// Default token provider name used by email confirmation, password reset, and change email. + /// public static readonly string DefaultProvider = "Default"; + + /// + /// Default token provider name used by the . + /// public static readonly string DefaultEmailProvider = "Email"; + + /// + /// Default token provider name used by the . + /// public static readonly string DefaultPhoneProvider = "Phone"; /// diff --git a/src/Microsoft.AspNetCore.Identity/TokenProviderDescriptor.cs b/src/Microsoft.AspNetCore.Identity/TokenProviderDescriptor.cs index 4f9df4ab08..993ecfbed2 100644 --- a/src/Microsoft.AspNetCore.Identity/TokenProviderDescriptor.cs +++ b/src/Microsoft.AspNetCore.Identity/TokenProviderDescriptor.cs @@ -5,13 +5,23 @@ using System; namespace Microsoft.AspNetCore.Identity { + /// + /// Used to represents a token provider in 's TokenMap. + /// public class TokenProviderDescriptor { + /// + /// Initializes a new instance of the class. + /// + /// The concrete type for this token provider. public TokenProviderDescriptor(Type type) { ProviderType = type; } + /// + /// The type that will be used for this token provider. + /// public Type ProviderType { get; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Identity/UserManager.cs b/src/Microsoft.AspNetCore.Identity/UserManager.cs index 1e201d09b6..103e794a57 100644 --- a/src/Microsoft.AspNetCore.Identity/UserManager.cs +++ b/src/Microsoft.AspNetCore.Identity/UserManager.cs @@ -23,7 +23,14 @@ namespace Microsoft.AspNetCore.Identity /// The type encapsulating a user. public class UserManager : IDisposable where TUser : class { + /// + /// The data protection purpose used for the reset password related methods. + /// protected const string ResetPasswordTokenPurpose = "ResetPassword"; + + /// + /// The data protection purpose used for the email confirmation related methods. + /// protected const string ConfirmEmailTokenPurpose = "EmailConfirmation"; private readonly Dictionary> _tokenProviders = @@ -344,6 +351,13 @@ namespace Microsoft.AspNetCore.Identity return principal.FindFirstValue(Options.ClaimsIdentity.UserIdClaimType); } + /// + /// Returns the user corresponding to the IdentityOptions.ClaimsIdentity.UserIdClaimType claim in + /// the principal or null. + /// + /// The principal which contains the user id claim. + /// The user corresponding to the IdentityOptions.ClaimsIdentity.UserIdClaimType claim in + /// the principal or null public virtual Task GetUserAsync(ClaimsPrincipal principal) { if (principal == null) @@ -2265,6 +2279,9 @@ namespace Microsoft.AspNetCore.Identity return cast; } + /// + /// Throws if this class has been disposed. + /// protected void ThrowIfDisposed() { if (_disposed) diff --git a/src/Microsoft.AspNetCore.Identity/project.json b/src/Microsoft.AspNetCore.Identity/project.json index 0b09fb0766..a354a9cc86 100644 --- a/src/Microsoft.AspNetCore.Identity/project.json +++ b/src/Microsoft.AspNetCore.Identity/project.json @@ -4,9 +4,6 @@ "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], "xmlDoc": true }, "packOptions": {