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

ModelBinderAttribute should not throw from BinderType property setter #2326

Closed
pranavkm opened this issue Apr 3, 2015 · 2 comments
Closed

Comments

@pranavkm
Copy link
Contributor

pranavkm commented Apr 3, 2015

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.ModelBinding/BinderMetadata/ModelBinderAttribute.cs#L34-L57

The BinderType setter throws when the type is not an IModelBinder. This is problematic since reflecting over the type decorated with the attribute would produce an exception. We already throw from the code consuming the attribute, which should suffice.

Example:

[ModelBinder(BinderType = typeof(string)]
public class MyModel {}

typeof(MyModel).GetCustomAttributes() <-- will throw
@pranavkm pranavkm added the bug label Apr 3, 2015
@rynowak
Copy link
Member

rynowak commented Apr 5, 2015

Example callstack? ModelMetadata? The code you provided is not common.

@danroth27 danroth27 added this to the 6.0.0-beta5 milestone Apr 6, 2015
@ianhong
Copy link
Contributor

ianhong commented Apr 15, 2015

9daf6b4

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