-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
Xamarin.Forms - DynamicExpressionParser.ParseLambda fails when comparing enum properties by their int value #479
Comments
Dear @ManuLin, Can you please provide a full (console) example project to show this error? |
Dear @StefH, Apparently the issue seems to be not when invoking this method within a .NET Standard class library or a .NET Core console application, but when invoking it from a Xamarin.Forms application. I setup a simple sample app to illustrate this issue, hope this helps. Please note: The problem is observed on all platforms supported by Xamarin.Forms. Regards, Manuel |
Thanks. I'll take a look. Did you try to name the property in the Foo-class differently? class Foo {
public MyEnum Abc { get; set; }
}
var lambdaParameter = new[] { Expression.Parameter(typeof(Foo), string.Empty) };
var expression = DynamicExpressionParser.ParseLambda(lambdaParameter, typeof(bool), "Abc= 1", parameters); |
When I rename the property I run into a different kind of exception. Considering your sample code above I face a System.Linq.Dynamic.Core.Exceptions.ParseException: No property or field 'MyEnum' exists in type 'Foo'. |
You also need |
In this case I run into the same ArgumentNullException as described in my initial comment. This is also reproducible with the example I provided. Value cannot be null. Parameter name: value |
Fix will be included in next version,. |
I am facing the following issue.
Consider the following setup:
When I invoke the following snippet
I obtain the correct lambda expression, however, when I'm using the associated integer values for comparison, e.g.
I run into an "System.ArgumentNullException: Value cannot be null. Parameter name: value" in a .NET Standard project.
System.Enum.ToObject (Type enumType, Object value) System.Linq.Dynamic.Core.Parser ExpressionPromoter.Promote (Expression expr, Type type, Boolean exact, Boolean convertExpr) System.Linq.Dynamic.Core.Parser ExpressionParser.ParseComparisonOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseLogicalAndOrOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseIn () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseAndOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseOrOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseLambdaOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseNullCoalescingOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.ParseConditionalOperator () System.Linq.Dynamic.Core.Parser ExpressionParser.Parse (Type resultType, Boolean createParameterCtor) System.Linq.Dynamic.Core DynamicExpressionParser.ParseLambda (ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
Interestingly everything works as expected when invoked in a project targeting the full .NET framework.
Any help is appreciated!
Best regards,
Manuel
The text was updated successfully, but these errors were encountered: