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

ReflectionExtensions.CreateInstanceFromString() does not handle empty integers #177

Open
JornWildt opened this issue Jun 6, 2019 · 1 comment

Comments

@JornWildt
Copy link

Given a handler like this:

public object some_handler(int? x = null)

registered with an URI like this:

.AtUri("/path?x={x}")

OpenRasta will assign NULL to x if the URL parameter "x" is not present in HTTP GET.

But if "x" is present, but empty as in "http://host/path?x=", OpenRasta will not detect "x" as empty - instead it fails to convert the empty string value of "x" to an integer and the result is that OpenRasta fails to match the method and yields the message "None of the operations had members that could be matches against the uri parameters: ..."

It can be argued that, yes, the empty string cannot be converted to integer - but you could also argue that it is a reasonable special case that makes your client implementation simpler (which IMHO is a good thing).

This is experienced in 2.5.2001 and may be changed in later versions of OpenRasta.

@serialseb
Copy link
Member

Thanks for that!
i think we switched to optional by default for querystring values in 2.1 or 2.5, so it'd make sense that with emtpy values, we would initialise with the default for that datatype.

I think it'd make sense to allow empty string for nullables without causing an error

@holytshirt waddayathink?

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

2 participants