Do you need to compile an expression "instance.Foo()" where Foo is a method that returns void? I would assume that you know beforehand that the method is going to be called instead of returning a value.
I have been able to get it to work (more or less), you need to compile to an Action<T> instead of a Func<T>. I created a new method on the CompiledExpression classes named CompileCall().
public Action CompileCall()
if (Expression == null) Expression = BuildTree();
For dynamic scope, it's a bit more difficult. You need to know beforehand whether your MemberAccess is going to return a value or not. In this case I think I would have to check if the memberAccess is the LAST token to be compiled, along with a flag that the
expression is going to be called instead of returning a value.
In the dynamic side the following should be called IF the member is returning void:
var binderM = Binder.InvokeMember(
expArgs.Select(x => CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null))
return Expression.Dynamic(binderM, typeof(void), expArgs);
I'll probably commit to a branch once I get the dynamic part working.