Skip to content

Use default if no value was bound for parameter #39427

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

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

captainsafia
Copy link
Member

Closes #38440

@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jan 11, 2022
@captainsafia captainsafia marked this pull request as ready for review January 11, 2022 06:07
@@ -546,7 +546,7 @@ private Task BindArgumentsAsync()
{
var parameterInfo = declaredParameterInfos[index];

if (!actionParameters.TryGetValue(parameterInfo.Name!, out var value))
if (!actionParameters.TryGetValue(parameterInfo.Name!, out var value) || value is null)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change feels innocuous enough, but do we know why this is needed? The code around here hasn't changed in ages.

Copy link
Member Author

Choose a reason for hiding this comment

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

The original issue reported the regression between .NET 5 and .NET 6. I was able to verify it as well. A quick peruse of the commit logs has me suspicious about some of the nullability changes that we made in this area for 6.0-preview4 but I, admittedly, haven't dug deeper. 🤷🏽‍♀️

@captainsafia captainsafia merged commit b611dc1 into dotnet:main Jan 11, 2022
@ghost ghost added this to the 7.0-preview1 milestone Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional parameter defaults in Controller Method are ignored.
2 participants