-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates
Milestone
Description
Describe the bug
We are testing preview bits on our application and we noticed that ModelBindingResult.Success no longer accepts null values with nullable annotations enabled. Is this intentional or a bug? We don't want to use ModelBindingResult.Failed as we explicitly binding the value to null and don't want other model binders to be used after.
Also didn't want to create new issues so here are other places with potentially incorrect nullability which don't compile now.
IModelBinderProvider.GetBinderreturn should be nullable, example in codebase BinderTypeModelBinderProvider.IUrlHelper.IsLocalUrl(string)parameter should be nullable, for example checking login redirect which can be null, example in codebase UrlHelperBase which checks for null too.
To Reproduce
#nullable enable
public class ModelBinder : IModelBinder
{
public Task BindModelAsync(ModelBindingContext bindingContext)
{
bindingContext.Result = ModelBindingResult.Success(null);
return Task.CompletedTask;
}
}Further technical details
Version: 5.0.100-preview.8.20417.9
Commit: fc62663a35
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates