Comments (5)
I have created a very minimalistic repository to reproduce the error on ios. It is an Xamarin.Forms project. When you start the iOs Project a exception is thrown, on Android not.
https://github.com/OPunktSchmidt/NRecoLambdaParser.Issue21.XamarinForms
This is the relevant test code. It is placed in App.xaml.cs and is exceuted immediately on when starting the project.
protected override void OnStart()
{
// Handle when your app starts
try
{
NReco.Linq.LambdaParser parser = new NReco.Linq.LambdaParser(new NReco.Linq.ValueComparer() { NullComparison = NReco.Linq.ValueComparer.NullComparisonMode.Sql });
string evalString = "(val1.Contains(val2) || val3.Contains(val4) || val5.Contains(val6) || val7.Contains(val8) || val9.Contains(val10) || val11.Contains(val12) || val13.Contains(val14) || val15.Contains(val16) || val17.Contains(val18) || val19.Contains(val20))";
System.Collections.Generic.Dictionary<string, object> values = new System.Collections.Generic.Dictionary<string, object>();
values.Add("val20", "10;");
values.Add("val17", "2;4;5;7;8;");
values.Add("val12", "6");
values.Add("val7", "2;4;5;7;8;");
values.Add("val2", "1");
values.Add("val19", "2;4;5;7;8;");
values.Add("val13", "2;4;5;7;8;");
values.Add("val8", "4");
values.Add("val3", "2;4;5;7;8;");
values.Add("val1", "2;4;5;7;8;");
values.Add("val5", "2;4;5;7;8;");
values.Add("val16", "8");
values.Add("val18", "9");
values.Add("val14", "7");
values.Add("val4", "2");
values.Add("val11", "2;4;5;7;8;");
values.Add("val9", "2;4;5;7;8;");
values.Add("val10", "5");
values.Add("val15", "2;4;5;7;8;");
values.Add("val6", "3");
object evalResult = parser.Eval(evalString, values);
System.Diagnostics.Debugger.Break();
}
catch (System.Exception ex)
{
System.Diagnostics.Debugger.Break();
}
}
from lambdaparser.
Oliver, do you have any idea how to fix this incompatibility on iOS? I don't have enough expertise on .net+mobile platform. It seems LambdaParser tries to create a delegate that doesn't available on ios (Func<>?).
from lambdaparser.
I haven't had a closer look. But in this depth I don't have much expertise in mobile development either.
I'll take a closer look at it. I'll be on vacation next week but I'll definitely get closer to it when I'm back in the office.
I'll keep you informed.
from lambdaparser.
I did some research.
"Since the iOS kernel prevents an application from generating code dynamically, Xamarin.iOS does not support any form of dynamic code generation." (https://docs.microsoft.com/bg-bg/xamarin/ios/internals/limitations)
Simple expressions like "val1 == val2" or "val1 > val2" seems to work on iOs, but more complex expressions like mine above not (there is a methode-call to "Contains in the expression).
Maybe the method-call to "Contains" requires something from namespace System.Reflection.Emit? System.Reflection.Emit is not available due to limitations under ios. I haven't worked much with dynamic code generation and System.Linq.Expressions so far so I can't say much about it.
Here are a few more interesting links:
https://stackoverflow.com/questions/19666257/how-to-compile-methodcallexpression-without-dynamicinvoke
https://stackoverflow.com/questions/24977939/what-does-expression-compile-do-on-monotouch
https://stackoverflow.com/questions/29245589/why-does-lambdaexpression-compile-work-on-ios-xamarin
I'll keep investigating...
from lambdaparser.
According to this documentation page, dynamic code generation is not supported on iOS; from the other side, NReco.LambdaParser uses only System.Expressions which should fallback to 'interpretation' mode on iOS. You reported that "val1 == val2" or "val1 > val2" work fine, so I may assume that an error may be caused by a bug related to the MethodCallExpression 'interpretation'.
First of all, it is good idea to test expression like "val3.Contains(val4)" with latest Xamarin platform, maybe this issue is already solved. If this doesn't help, you can modify LambdaParser class to use Expression.Compile(true) to force interpretation mode - who knows maybe this is needed for iOS.
Finally, execution of expressions on iOS 100% might be possible with own LambdaParser 'interpretation' (however this will require some development + I assume evaluation performance may be not so good).
from lambdaparser.
Related Issues (20)
- LambdaParser.Parse HOT 1
- Linq Functions Suppport HOT 2
- SL5 MacOs support HOT 3
- nested expression in dictionary indexer
- Security? HOT 7
- Allow recursivity HOT 5
- Math Operations like power (exponentiate) and to extract a root -possible? HOT 2
- Error - Filter Datatable with LINQ inside the .Eval function HOT 4
- Lambda Sum or Select HOT 1
- Changing order of parameters in simple expression produces different evaluation result. HOT 5
- Expressions using "not" not always work HOT 4
- Support for dynamic types like expando object
- Parser Context Security HOT 1
- "Expected value" error in simple expression HOT 2
- Non-convertible types support
- Variables in expressions HOT 1
- Sequence of ternary operators HOT 1
- How to throw exception? HOT 1
- it is not support Convert HOT 1
- The problem of checking expression statements HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lambdaparser.