Пример #1
0
        public void UserDefinedClass()
        {
            // We can use the simplest version of GetMethod because we already know only one
            // exists in the very simple class we're using for the tests.
            var mi = typeof(OpClass).GetMethod("op_Addition");

            var left = new OpClass();
            var expr = Expression.Add(Expression.Constant(left), Expression.Constant(new OpClass()));

            Assert.AreEqual(ExpressionType.Add, expr.NodeType, "Add#09");
            Assert.AreEqual(typeof(OpClass), expr.Type, "Add#10");
            Assert.AreEqual(mi, expr.Method, "Add#11");
            Assert.AreEqual("op_Addition", expr.Method.Name, "Add#12");
            Assert.AreEqual("(value(MonoTests.System.Linq.Expressions.OpClass) + value(MonoTests.System.Linq.Expressions.OpClass))",
                            expr.ToString(), "Add#13");

            Expression.Lambda <Func <OpClass> >(expr);

#if false
            //
            // We do not have support for objects that are not really
            // constants, like this case.   Need to figure out what to do
            // with those
            //

            Func <OpClass> compiled = l.Compile();
            Assert.AreEqual(left, compiled());
#endif
        }
Пример #2
0
        public void UserClassValue()
        {
            OpClass            oc   = new OpClass();
            ConstantExpression expr = Expression.Constant(oc);

            Assert.AreEqual(ExpressionType.Constant, expr.NodeType, "Constant#29");
            Assert.AreEqual(oc, expr.Value, "Constant#30");
            Assert.AreEqual(typeof(OpClass), expr.Type, "Constant#31");
            Assert.AreEqual("value(MonoTests.System.Linq.Expressions.OpClass)", expr.ToString(), "Constant#32");
        }
Пример #3
0
 public static OpClass WrongUnaryParameterCount(OpClass a, OpClass b)
 {
     GC.KeepAlive(b);
     return(a);
 }
Пример #4
0
 public OpClass WrongUnaryNotStatic(OpClass a)
 {
     return(a);
 }
Пример #5
0
 public static void WrongUnaryReturnVoid(OpClass a)
 {
     GC.KeepAlive(a);
 }
Пример #6
0
 public static OpClass WrongUnaryParameterCount(OpClass a, OpClass b)
 {
     Theraot.No.Op(b);
     return(a);
 }
Пример #7
0
 public static void WrongUnaryReturnVoid(OpClass a)
 {
     Theraot.No.Op(a);
 }
Пример #8
0
 public static OpClass WrongUnaryParameterCount(OpClass a, OpClass b)
 {
     return(a);
 }
Пример #9
0
 public static void WrongUnaryReturnVoid(OpClass a)
 {
 }