Skip to content

Commit 8a662c0

Browse files
committed
Avoid changing schema
1 parent 39ddeea commit 8a662c0

26 files changed

+1587
-67
lines changed

src/Identity/EntityFrameworkCore/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PackageTags>aspnetcore;entityframeworkcore;identity;membership</PackageTags>
8-
<NoWarn>$(NoWarn);RS0036</NoWarn>
9-
108
</PropertyGroup>
119

1210
<ItemGroup>

src/Identity/EntityFrameworkCore/src/PublicAPI.Unshipped.txt

Lines changed: 251 additions & 1 deletion
Large diffs are not rendered by default.

src/Identity/EntityFrameworkCore/src/RoleStore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ protected virtual async Task SaveChanges(CancellationToken cancellationToken)
220220
/// <param name="role">The role whose name should be returned.</param>
221221
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
222222
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
223-
public virtual Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
223+
public virtual Task<string?> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
224224
{
225225
cancellationToken.ThrowIfCancellationRequested();
226226
ThrowIfDisposed();
@@ -238,7 +238,7 @@ protected virtual async Task SaveChanges(CancellationToken cancellationToken)
238238
/// <param name="roleName">The name of the role.</param>
239239
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
240240
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
241-
public virtual Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken = default(CancellationToken))
241+
public virtual Task SetRoleNameAsync(TRole role, string? roleName, CancellationToken cancellationToken = default(CancellationToken))
242242
{
243243
cancellationToken.ThrowIfCancellationRequested();
244244
ThrowIfDisposed();
@@ -311,7 +311,7 @@ protected virtual async Task SaveChanges(CancellationToken cancellationToken)
311311
/// <param name="role">The role whose normalized name should be retrieved.</param>
312312
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
313313
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
314-
public virtual Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
314+
public virtual Task<string?> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
315315
{
316316
cancellationToken.ThrowIfCancellationRequested();
317317
ThrowIfDisposed();
@@ -329,7 +329,7 @@ protected virtual async Task SaveChanges(CancellationToken cancellationToken)
329329
/// <param name="normalizedName">The normalized name to set</param>
330330
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
331331
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
332-
public virtual Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken = default(CancellationToken))
332+
public virtual Task SetNormalizedRoleNameAsync(TRole role, string? normalizedName, CancellationToken cancellationToken = default(CancellationToken))
333333
{
334334
cancellationToken.ThrowIfCancellationRequested();
335335
ThrowIfDisposed();
@@ -371,7 +371,7 @@ protected void ThrowIfDisposed()
371371
throw new ArgumentNullException(nameof(role));
372372
}
373373

374-
return await RoleClaims.Where(rc => rc.RoleId.Equals(role.Id)).Select(c => new Claim(c.ClaimType, c.ClaimValue)).ToListAsync(cancellationToken);
374+
return await RoleClaims.Where(rc => rc.RoleId.Equals(role.Id)).Select(c => new Claim(c.ClaimType!, c.ClaimValue!)).ToListAsync(cancellationToken);
375375
}
376376

377377
/// <summary>

src/Identity/Extensions.Core/src/DefaultPersonalDataProtector.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Diagnostics;
56

67
namespace Microsoft.AspNetCore.Identity;
78

@@ -30,8 +31,9 @@ public DefaultPersonalDataProtector(ILookupProtectorKeyRing keyRing, ILookupProt
3031
/// </summary>
3132
/// <param name="data">The data to unprotect.</param>
3233
/// <returns>The unprotected data.</returns>
33-
public virtual string Unprotect(string data)
34+
public virtual string? Unprotect(string? data)
3435
{
36+
Debug.Assert(data != null);
3537
var split = data.IndexOf(':');
3638
if (split == -1 || split == data.Length - 1)
3739
{
@@ -47,7 +49,7 @@ public virtual string Unprotect(string data)
4749
/// </summary>
4850
/// <param name="data">The data to protect.</param>
4951
/// <returns>The protected data.</returns>
50-
public virtual string Protect(string data)
52+
public virtual string? Protect(string? data)
5153
{
5254
var current = _keyRing.CurrentKeyId;
5355
return current + ":" + _encryptor.Protect(current, data);

src/Identity/Extensions.Core/src/ILookupProtector.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Identity;
57

68
/// <summary>
@@ -14,13 +16,15 @@ public interface ILookupProtector
1416
/// <param name="keyId">The key to use.</param>
1517
/// <param name="data">The data to protect.</param>
1618
/// <returns>The protected data.</returns>
17-
string Protect(string keyId, string data);
19+
[return: NotNullIfNotNull("data")]
20+
string? Protect(string keyId, string? data);
1821

1922
/// <summary>
2023
/// Unprotect the data using the specified key.
2124
/// </summary>
2225
/// <param name="keyId">The key to use.</param>
2326
/// <param name="data">The data to unprotect.</param>
2427
/// <returns>The original data.</returns>
25-
string Unprotect(string keyId, string data);
28+
[return: NotNullIfNotNull("data")]
29+
string? Unprotect(string keyId, string? data);
2630
}

src/Identity/Extensions.Core/src/IPersonalDataProtector.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Identity;
57

68
/// <summary>
@@ -13,12 +15,14 @@ public interface IPersonalDataProtector
1315
/// </summary>
1416
/// <param name="data">The data to protect.</param>
1517
/// <returns>The protected data.</returns>
16-
string Protect(string data);
18+
[return: NotNullIfNotNull("data")]
19+
string? Protect(string? data);
1720

1821
/// <summary>
1922
/// Unprotect the data.
2023
/// </summary>
2124
/// <param name="data"></param>
2225
/// <returns>The unprotected data.</returns>
23-
string Unprotect(string data);
26+
[return: NotNullIfNotNull("data")]
27+
string? Unprotect(string? data);
2428
}

src/Identity/Extensions.Core/src/IRoleStore.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public interface IRoleStore<TRole> : IDisposable where TRole : class
5151
/// <param name="role">The role whose name should be returned.</param>
5252
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
5353
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
54-
Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken);
54+
Task<string?> GetRoleNameAsync(TRole role, CancellationToken cancellationToken);
5555

5656
/// <summary>
5757
/// Sets the name of a role in the store as an asynchronous operation.
@@ -60,15 +60,15 @@ public interface IRoleStore<TRole> : IDisposable where TRole : class
6060
/// <param name="roleName">The name of the role.</param>
6161
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
6262
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
63-
Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken);
63+
Task SetRoleNameAsync(TRole role, string? roleName, CancellationToken cancellationToken);
6464

6565
/// <summary>
6666
/// Get a role's normalized name as an asynchronous operation.
6767
/// </summary>
6868
/// <param name="role">The role whose normalized name should be retrieved.</param>
6969
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
7070
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
71-
Task<string> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken);
71+
Task<string?> GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken);
7272

7373
/// <summary>
7474
/// Set a role's normalized name as an asynchronous operation.
@@ -77,7 +77,7 @@ public interface IRoleStore<TRole> : IDisposable where TRole : class
7777
/// <param name="normalizedName">The normalized name to set</param>
7878
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
7979
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
80-
Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken);
80+
Task SetNormalizedRoleNameAsync(TRole role, string? normalizedName, CancellationToken cancellationToken);
8181

8282
/// <summary>
8383
/// Finds the role who has the specified ID as an asynchronous operation.

src/Identity/Extensions.Core/src/IUserAuthenticationTokenStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface IUserAuthenticationTokenStore<TUser> : IUserStore<TUser> where
2121
/// <param name="value">The value of the token.</param>
2222
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
2323
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
24-
Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken);
24+
Task SetTokenAsync(TUser user, string loginProvider, string name, string? value, CancellationToken cancellationToken);
2525

2626
/// <summary>
2727
/// Deletes a token for a user.

src/Identity/Extensions.Core/src/IUserStore.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface IUserStore<TUser> : IDisposable where TUser : class
2727
/// <param name="user">The user whose name should be retrieved.</param>
2828
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
2929
/// <returns>The <see cref="Task"/> that represents the asynchronous operation, containing the name for the specified <paramref name="user"/>.</returns>
30-
Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken);
30+
Task<string?> GetUserNameAsync(TUser user, CancellationToken cancellationToken);
3131

3232
/// <summary>
3333
/// Sets the given <paramref name="userName" /> for the specified <paramref name="user"/>.
@@ -36,15 +36,15 @@ public interface IUserStore<TUser> : IDisposable where TUser : class
3636
/// <param name="userName">The user name to set.</param>
3737
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
3838
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
39-
Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken);
39+
Task SetUserNameAsync(TUser user, string? userName, CancellationToken cancellationToken);
4040

4141
/// <summary>
4242
/// Gets the normalized user name for the specified <paramref name="user"/>.
4343
/// </summary>
4444
/// <param name="user">The user whose normalized name should be retrieved.</param>
4545
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
4646
/// <returns>The <see cref="Task"/> that represents the asynchronous operation, containing the normalized user name for the specified <paramref name="user"/>.</returns>
47-
Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken);
47+
Task<string?> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken);
4848

4949
/// <summary>
5050
/// Sets the given normalized name for the specified <paramref name="user"/>.
@@ -53,7 +53,7 @@ public interface IUserStore<TUser> : IDisposable where TUser : class
5353
/// <param name="normalizedName">The normalized name to set.</param>
5454
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
5555
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
56-
Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken);
56+
Task SetNormalizedUserNameAsync(TUser user, string? normalizedName, CancellationToken cancellationToken);
5757

5858
/// <summary>
5959
/// Creates the specified <paramref name="user"/> in the user store.

src/Identity/Extensions.Core/src/IdentityErrorDescriber.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public virtual IdentityError LoginAlreadyAssociated()
9696
/// </summary>
9797
/// <param name="userName">The user name that is invalid.</param>
9898
/// <returns>An <see cref="IdentityError"/> indicating the specified user <paramref name="userName"/> is invalid.</returns>
99-
public virtual IdentityError InvalidUserName(string userName)
99+
public virtual IdentityError InvalidUserName(string? userName)
100100
{
101101
return new IdentityError
102102
{
@@ -152,7 +152,7 @@ public virtual IdentityError DuplicateEmail(string email)
152152
/// </summary>
153153
/// <param name="role">The invalid role.</param>
154154
/// <returns>An <see cref="IdentityError"/> indicating the specific role <paramref name="role"/> name is invalid.</returns>
155-
public virtual IdentityError InvalidRoleName(string role)
155+
public virtual IdentityError InvalidRoleName(string? role)
156156
{
157157
return new IdentityError
158158
{

0 commit comments

Comments
 (0)