This project has moved and is read-only. For the latest updates, please go here.

Add/Subtract tests (CompiledExpression<T>) failing

Oct 23, 2016 at 12:29 AM
Edited Oct 23, 2016 at 12:30 AM
from source as of "commit 991ce60420c1, Mar 25, 2014"

both add and subtract are failing with message

"typed expression Expression of type 'System.Object' cannot be used for return type 'System.Int32'"

Potential solution is:

Add method to ExpressionCompiler that converts to T instead of Object
        protected Expression WrapExpression<T>(Expression source)
            if (source.Type != typeof(void))
                return Expression.Convert(source, typeof(T));
            return Expression.Block(source, Expression.Constant(null));
Change CompiledExpression<T>.Compile to use the new method.
        public Func<T> Compile(bool isCall = false)
            if (Expression == null) Expression = WrapExpression<T>(BuildTree());
            return Expression.Lambda<Func<T>>(Expression).Compile();