-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Can't setup protected methods with nullable parameters #92
Comments
I took a quick peek in the code and I believe the solution can be implemented easily. The reason for the problem is that when nullable values are cast to The solution is that in Here are my modified versions of private static Expression ToExpressionArg(ParameterInfo paramInfo, object arg)
{
var lambda = arg as LambdaExpression;
if (lambda != null)
{
return lambda.Body;
}
var expression = arg as Expression;
if (expression != null)
{
return expression;
}
return Expression.Constant(arg, paramInfo.ParameterType);
}
private static IEnumerable<Expression> ToExpressionArgs(MethodInfo method, object[] args)
{
ParameterInfo[] methodParams = method.GetParameters();
for (int i = 0; i < args.Length; i++)
{
yield return ToExpressionArg(methodParams[i], args[i]);
}
} |
Looks good! Want to send a PR so you get credited appropriately and this fix makes it /kzu from mobile
|
@kzu: Unfortunately, I don't have any git integration set up (we're a TFS-based shop) and I don't have time to get it all set up and create a PR. I don't really care about being credited, so if you or someone else would be able to integrate the change, that would be great. Thanks! |
Pull request #200 (single commit). |
…s with nullable parameters
…d methods with nullable parameters" This reverts commit f413644.
…s with nullable parameters
@kzu Any reason why the pull request hasn't been merged yet? |
… with nullable parameters" This reverts commit f413644.
I guess we can close this issue, now that #200 has been merged. |
It seems that it's not possible to set up a protected method if it has nullable parameters.
Example:
The output of running this program is an
ArgumentException
with the following message:Expression of type 'System.Int32' cannot be used for parameter of type 'System.Nullable
1[System.Int32]' of method 'Void MyMethod(System.Nullable
1[System.Int32])'The text was updated successfully, but these errors were encountered: