You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you add a variable to the interpreter that is a dynamic/ExpandoObject with a string member, then attempt to use that string member in a function, you get an exception: DynamicExpresso.Exceptions.ParseException : Argument list incompatible with delegate expression (at index 0).
Here is a test that demonstrates the behavior.
varevaluator=newInterpreter();// create path helper functions in expressions...Func<string,string,string>pathCombine=(x,y)=>System.IO.Path.Combine(x,y);evaluator.SetFunction("PathCombine",pathCombine);// add a GlobalSettings dynamic object...dynamicglobalSettings=newExpandoObject();globalSettings.MyTestPath="C:\\delme\\";evaluator.SetVariable("GlobalSettings",globalSettings);// Here is a workaround that succeeds - you have to cast GlobalSettings.MyTestPath to string:stringworks=(string)evaluator.Eval("PathCombine((string)GlobalSettings.MyTestPath,\"test.txt\")");Assert.That(works,Is.EqualTo("C:\\delme\\test.txt"));// I think this should work, but doesn't:stringdoesntWork=(string)evaluator.Eval("PathCombine(GlobalSettings.MyTestPath,\"test.txt\")");Assert.That(doesntWork,Is.EqualTo("C:\\delme\\test.txt"));
Because PathCombine takes a string, and GlobalSettings.MyTestPath is a string, I think this should work?
The text was updated successfully, but these errors were encountered:
Pentiva
added a commit
to Pentiva/DynamicExpresso
that referenced
this issue
Sep 14, 2023
If you add a variable to the interpreter that is a dynamic/ExpandoObject with a string member, then attempt to use that string member in a function, you get an exception:
DynamicExpresso.Exceptions.ParseException : Argument list incompatible with delegate expression (at index 0).
Here is a test that demonstrates the behavior.
Because PathCombine takes a string, and GlobalSettings.MyTestPath is a string, I think this should work?
The text was updated successfully, but these errors were encountered: