This project has moved. For the latest updates, please go here.

General Usage

Mar 3, 2014 at 3:38 PM
First of all, thanks Rupert for your effort with this project. I am currently trying to use it to build a set of automated test instructions to be run with hardware tools connected to my PC.

So I'm trying to understand the boundaries of what is possible.

For example, I can't register an object and call a void() method on that object.

For example.

public void Drive() { }

So then I need to redefine it as a function which returns a value (say an int or null object)?

Would this be ok??

public int Drive() { // Do something; return 0; }

I don't need the return value for anything...I just want to execute some code.
Also, you can't assign properties, correct?

So I can't say...

Car.NumberOfWheels = 4;

I need to redefine as a function.

public int Car.SetNumberOfWheels(4)

This is how I understand everything from the discussion and usage examples. Sorry if they are really basic.
Mar 5, 2014 at 2:20 AM
Edited Mar 5, 2014 at 2:25 AM
Thanks for your interest in the project!

I've recently added support for calling void-returning functions (get the latest codes in the main branch), but you have to use Call or Compile() instead of Eval() and Compile().

As for assigning properties, no it does not support that yet, but perhaps with support for calling it may be possible in the near future. However, your assumptions are correct.

I'm curious, what benefit does having dynamic runtime compilation have with the project you are working on? and why you need to call void functions and assign values?

Reason I ask is because ExpressionEvaluator was initially designed to evaluate expressions, which means returning values, but I 'm beginning to see some interest in calling methods and assigning variables, and it would help a lot if I knew in what context ExpressionEval was being used, so I could perhaps add better support for these kinds of things in a meaningful way.
Mar 5, 2014 at 3:32 PM

Thanks for the info.

You asked why I would want to have dynamic run-time compilation with my project. Here is one example that is relevant for my case.

I am building a project that lets users of my company create user controls at run-time that are actually used to manage hardware ports for digital and analog signal signals. For example, a user could create a control that manipulates an analog output electrical signal or reads an analog input signal.

Now, I don't what the user is doing with these signals, but I know that they want to build a set of automated tests for them. Maybe they want to output an analog sine wave from their computer.

So, because I give them access to a set number of object variables, like time (Test.RegisterType(DateTime, "time")) or the user control (Test.RegisterType(AnalogControl, "analogControl"), this would give the user complete control of how they want to run their test.

I have specified in my user interface a way to users to type in their tests in a specified manner. See, the user needs to have end-to-end control. That gives them complete freedom to do what they want in a manner they can understand. I am not really using ExpressionEvaluator to evaluate expressions that are pre-defined in code.

So, given this, it makes sense for the user to write "analogControl.Value = Math.Sin(time)" rather than "analogControl.WriteValue(Math.Sin(time))".

Now, like I said, this is a great project and I can make it work the way I want it to. I just needed to understand its boundaries as it currently stands. As a developer myself, I know how hard it is to redesign frameworks like this, so I am sympathetic to that aspect.

Thanks for your effort.
Mar 6, 2014 at 11:18 AM

Turns out I already had assignment implemented, but it wasn't really useful until I implemented CompileCall and related functions. Try the latest commits.= and let me know if this works for you.
            var c1 = new CompiledExpression() { StringToParse = "X = 99" };
            var f1 = c1.ScopeCompileCall<MyClass>();
Mar 7, 2014 at 7:32 PM
Edited Mar 7, 2014 at 7:38 PM

Has the download link been updated? It currently reads

It didn't seem to recognize the Call and ScopeCompileCall. Should I build the solution from your commits instead?


Got it from the source code. It doesn't seemed to be versioned as no matter.
Mar 9, 2014 at 2:03 AM
No I haven't released a build for those changes yet. Were the changes useful to your project?