Skip to content

Conversation

@pranavkm
Copy link
Contributor

No description provided.

@pranavkm pranavkm requested a review from Pilchie as a code owner February 12, 2022 03:00
@ghost ghost added the area-identity Includes: Identity and providers label Feb 12, 2022
@pranavkm pranavkm requested review from HaoK and Tratcher February 12, 2022 03:00
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.

/// </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