Allow null on UserOptions.AllowedUserNameCharacters#67731
Open
justindbaur wants to merge 3 commits into
Open
Conversation
Contributor
|
Thanks for your PR, @justindbaur. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates ASP.NET Core Identity’s UserOptions.AllowedUserNameCharacters to explicitly allow null (via nullable reference types) to represent “no character restrictions,” aligning the API contract with existing runtime behavior.
Changes:
- Update
UserOptions.AllowedUserNameCharactersfromstringtostring?. - Add XML documentation clarifying the meaning of
nullfor the option.
| /// The list of allowed characters in the username used to validate user names. | ||
| /// </value> | ||
| public string AllowedUserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+"; | ||
| public string? AllowedUserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+"; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| Microsoft.AspNetCore.Identity.UserManager<TUser>.ValidateUserAsync(TUser! user) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult!>! | ||
| Microsoft.AspNetCore.Identity.UserOptions | ||
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string! | ||
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.set -> void |
Comment on lines
1
to
4
| #nullable enable | ||
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string? | ||
| Microsoft.AspNetCore.Identity.UserPasskeyInfo.Aaguid.get -> byte[]? | ||
| Microsoft.AspNetCore.Identity.UserPasskeyInfo.Aaguid.set -> void |
halter73
reviewed
Jul 14, 2026
| @@ -1,3 +1,4 @@ | |||
| #nullable enable | |||
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string? | |||
Member
There was a problem hiding this comment.
Thanks for doing this! I think the correct syntax for modifying the nullability of an existing member is this:
Suggested change
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string? | |
| *REMOVED*Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string! | |
| Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string? |
Then you can undo the changes is PublicAPI.Shipped.txt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow
nullonUserOptions.AllowedUserNameCharactersAllow
nullonUserOptions.AllowedUserNameCharactersto denote that all characters are allowed in a user name.Description
There are already tests validating that when null is set to this option that non-alphanumeric characters are allowed in user names. This just makes it clear from the type system that
nullis allowed here and has a meaning.aspnetcore/src/Identity/test/Identity.Test/UserValidatorTest.cs
Line 77 in b50ab86
Fixes #64078