New TryParseModelBinder#40233
Merged
Merged
Conversation
davidfowl
reviewed
Feb 15, 2022
davidfowl
reviewed
Feb 15, 2022
brunolins16
commented
Feb 15, 2022
pranavkm
reviewed
Feb 16, 2022
pranavkm
reviewed
Feb 17, 2022
pranavkm
reviewed
Feb 20, 2022
Co-authored-by: Brennan <brecon@microsoft.com>
…ns16/aspnetcore into brunolins16/issues/39682
BrennanConroy
approved these changes
Feb 28, 2022
pranavkm
approved these changes
Mar 3, 2022
Contributor
pranavkm
left a comment
There was a problem hiding this comment.
Thanks for driving this PR!
| } | ||
| catch (InvalidOperationException) | ||
| { | ||
| // The ParameterBindingMethodCache.FindTryParseMethod throws an exception |
Contributor
There was a problem hiding this comment.
Suggestion - we could update FindTryParseMethod to not throw via an additional parameter. Not catching exceptions is certainly a lot nicer since it avoids things like first-chance exceptions in VS.
Member
Author
There was a problem hiding this comment.
Agree. I will open a new PR just for that, ok?
| Expression.Block( | ||
| Expression.Assign(modelValue, Expression.Convert(parsedValue, modelValue.Type)), | ||
| Expression.Assign(BindingResultExpression, Expression.Call(SuccessBindingResultMethod, modelValue))), | ||
| Expression.Call(AddModelErrorMethod, BindingContextExpression, Expression.Constant(new FormatException()))), |
Contributor
There was a problem hiding this comment.
Should the format exception use https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelBindingMessageProvider.cs#L41-L47 as the message?
Member
Author
There was a problem hiding this comment.
That is exactly what the TryAddModelError will do:
Co-authored-by: Pranav K <prkrishn@hotmail.com>
…ns16/aspnetcore into brunolins16/issues/39682
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.
Fixes #39682