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

SL5 MacOs support #26

Open
wtlatli opened this issue Jun 17, 2020 · 3 comments
Open

SL5 MacOs support #26

wtlatli opened this issue Jun 17, 2020 · 3 comments

Comments

@wtlatli
Copy link

wtlatli commented Jun 17, 2020

I am using LambdaParser in a SL5 application, every thing is working correctly on Windows clients, but formulas are not evaluated on MacOs. The application is running with elevated privileges (signed and OOB).
Maybe need to reference some extra assemblies ?

@VitaliyMF
Copy link
Contributor

VitaliyMF commented Jun 18, 2020

Extra assemblies are 100% not needed.

LambdaParser uses Expression.Compile (from System.Linq.Expression) to get the evaluation result. Maybe on MacOS this API has limitations like on iOS?.. (see #21).

Unfortunately, I don't have Mac and cannot propose a workaround by myself.
Could you try to do the following: modify https://github.com/nreco/lambdaparser/blob/master/src/NReco.LambdaParser/Linq/LambdaParser.cs line 110 and replace "Compile()" with "Compile(true)" (this enables Expression interpretation instead of compilation), then build NReco.LambdaParser.dll and try it on MacOS? If this helps we can add an option for LambdaParser class to use this mode.

If this doesn't help: add own implementation of expression interpreter as an alternative to "Expression.Compile" (this solution 100% will work, but requires some development - your contribution is welcome).

@wtlatli
Copy link
Author

wtlatli commented Jun 20, 2020

Thank you for your response.

I've tryed to implement the proposed workaroud but faced 2 problems:
1- Version 1.0.11 doesnt support PCL natively => had to renenable desired target platform.
2- Compile(bool preferInterpretation) isn't supported for PCL, and I think that Linq's LambdaExpression.Compile() in PCL is already using the interpreter:

public Delegate Compile(bool preferInterpretation)
{
#if FEATURE_COMPILE
#if FEATURE_INTERPRET
if (preferInterpretation)
{
return new Interpreter.LightCompiler().CompileTop(this).CreateDelegate();
}
#endif
return Compiler.LambdaCompiler.Compile(this);
#else
return new Interpreter.LightCompiler().CompileTop(this).CreateDelegate();
#endif
}

Implementing own Expression.Compile seems to be quite complex and require a huge development effort that I'm not able to do.

@VitaliyMF
Copy link
Contributor

PCL targets are legacy. They are not supported any more by an official build on nuget.org.

Regarding

Implementing own Expression.Compile seems to be quite complex and require a huge development effort that I'm not able to do.

adding own 'interpretation' mode is not a very complex, in fact. Number of operators that are possible in LambdaParser expressions is known and rather limited; to make method/property calls existing helpers may be used. However, interpretation is a much slower than a call of compiled delegate (this may be important if you need to evaluate an expression a lot of times quickly).

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