Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Removing IInputFormatterSelector #2353

Merged
merged 1 commit into from
Apr 8, 2015
Merged

Removing IInputFormatterSelector #2353

merged 1 commit into from
Apr 8, 2015

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Apr 7, 2015

Follow up work item to #2269

@ghost ghost added the cla-not-required label Apr 7, 2015
@@ -48,7 +47,7 @@ public BodyModelBinder()
return new ModelBindingResult(model: null, key: bindingContext.ModelName, isModelSet: false);
}

object model = null;
object model;
Copy link
Member

Choose a reason for hiding this comment

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

You can safely move this all of the way into the try

@rynowak
Copy link
Member

rynowak commented Apr 7, 2015

:shipit:

@pranavkm pranavkm force-pushed the InputFormatterSelector branch from 635bd34 to 6e21c2c Compare April 7, 2015 23:36
@pranavkm
Copy link
Contributor Author

pranavkm commented Apr 7, 2015

Updated with some dead code cleanup + new functional tests

}
catch (Exception ex)
{
model = GetDefaultValueForType(bindingContext.ModelType);
bindingContext.ModelState.AddModelError(bindingContext.ModelName, ex);

// This model binder is the only handler for the Body binding source.
// Always tell the model binding system to skip other model binders i.e. return non-null.
return new ModelBindingResult(model: null, key: bindingContext.ModelName, isModelSet: false);
Copy link
Member

Choose a reason for hiding this comment

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

This was my bad. I think the first parameter here was supposed to be assigned the default value for type model calculated above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That said, it seems like fixing it specifically for BodyModelBinder is incorrect and we should have a single top level piece of code that addresses this, not individual binders.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@kichalla
Copy link
Member

kichalla commented Apr 8, 2015

:shipit:

@@ -127,6 +127,43 @@ public class InputFormatterTests
}

[Theory]
[InlineData("\"I'm a JSON string!\"")]
[InlineData("true")]
public async Task JsonInputFormatter_ReturnsDefaultValue_ForValueTypes(string input)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about an empty string content? that should be treated as a null value and a model state error should be added by JsonInputformatter

@harshgMSFT
Copy link
Contributor

⌚ on one test case.

Follow up work item to #2269
@pranavkm pranavkm force-pushed the InputFormatterSelector branch from 6e21c2c to 43e24b2 Compare April 8, 2015 17:12
@pranavkm
Copy link
Contributor Author

pranavkm commented Apr 8, 2015

Updated.

@harshgMSFT
Copy link
Contributor

:shipit:

@pranavkm pranavkm merged commit 43e24b2 into dev Apr 8, 2015
@pranavkm pranavkm deleted the InputFormatterSelector branch April 8, 2015 19:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants