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

Move call to validate constructor in ComplexTypeModelBinder into CreateModel #5801

Closed
rynowak opened this issue Feb 14, 2017 · 3 comments
Closed

Comments

@rynowak
Copy link
Member

rynowak commented Feb 14, 2017

See commit here: 842d661

This check should be in CanCreateModel so that it will be skipped for someone who subclassed ComplexTypeModelBinder

Also, this change adds runtime reflection to pretty hot codepath just for validation purposes. We can do this one time per-instance by moving it to the inside of this block:

if (_modelCreator == null)	
{
}
@rynowak
Copy link
Member Author

rynowak commented Feb 14, 2017

/cc @kichalla @dougbu

@Eilon Eilon added this to the 1.1.2 milestone Feb 14, 2017
@rynowak rynowak changed the title Cache call to GetConstructors in ComplexTypeModelBinder Move call to validate constructor in ComplexTypeModelBinder into CreateModel Feb 14, 2017
@dougbu
Copy link
Member

dougbu commented Feb 14, 2017

@rynowak you're talking about a bigger refactorization of ComplexTypeModelBinder than immediately evident. For one thing, the _modelCreator == null check is in CreateModel() and not CanCreateModel(); moving the constructor check there would be kinda late. For another, CanCreateModel() has a couple of successful return paths that'll need to change.

Of course, if the uncached reflection shows up in profiles, party on.

@rynowak
Copy link
Member Author

rynowak commented Feb 14, 2017

This check should be in CanCreateModel so that it will be skipped for someone who subclassed ComplexTypeModelBinder

I'm suggesting we fix this scenario, which we've directed people to do, as part of the patch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants