Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeAttribute causes Microsoft.CSharp.RuntimeBinder.RuntimeBinderException #775

Closed
LuukN2 opened this issue Sep 13, 2018 · 0 comments
Closed

Comments

@LuukN2
Copy link

LuukN2 commented Sep 13, 2018

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '>' cannot be applied to operands of type 'string' and 'double'.

If I use a range attribute like this:
[Range(typeof(decimal), "0", "1")]
The exception is thrown in the ApplyDataAnnotations method in JsonSchemaGenerator.cs.

This is probably because the used constructor for the RangeAttribute sets the properties Minimum and Maximum to a string value and this causes the comparison done at line 945 in JsonSchemaGenerator to throw the exception.

if (rangeAttribute.Minimum != null && rangeAttribute.Minimum > double.MinValue)

All you need to do to reproduce this exception is to use the Range attribute on a decimal property like I did.

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

No branches or pull requests

1 participant