Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nullability to Identity / Identity.UI #40167

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

pranavkm
Copy link
Contributor

No description provided.

@ghost ghost added the area-identity Includes: Identity and providers label Feb 12, 2022
@@ -36,7 +36,7 @@ public SecurityStampValidator(IOptions<SecurityStampValidatorOptions> options, S
SignInManager = signInManager;
Options = options.Value;
Clock = clock;
Logger = logger.CreateLogger(this.GetType().FullName);
Logger = logger.CreateLogger(GetType());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight functional change.

@@ -27,26 +27,26 @@ public class ExternalLoginModel : PageModel
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
[BindProperty]
public InputModel Input { get; set; }
public InputModel Input { get; set; } = default!;
Copy link
Contributor Author

@pranavkm pranavkm Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned this to @DamianEdwards - the Input property is only bound in OnPost and it would make more sense to mark this as nullable. However this has two annoying issues:

a) ModelExpression - which is what you get if you do <input asp-for"Input.Name" /> is a expression tree which does not support using null propagation. MVC handles null-values in the expression tree, but as a user you're forced to use a null-forgiveness operator which doesn't feel nice: <input asp-for"Input!.Name" />

b) You end up having to also assert that this value is non-null in every OnPost.

Making it non-nullable seems like a cheeky but less painful way to go about this.

@pranavkm pranavkm merged commit 84c0baa into dotnet:main Feb 15, 2022
@pranavkm pranavkm deleted the nullable-identity branch February 15, 2022 21:02
@ghost ghost added this to the 7.0-preview2 milestone Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-identity Includes: Identity and providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants