Exemple #1
0
 public void MembersBuiltin()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 1.23m.ToString());
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Enum)(object)AttributeTargets.All).HasFlag((Enum)AttributeTargets.Assembly));
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => "abc".Length == 3);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 'a'.CompareTo('b') < 0);
 }
Exemple #2
0
 public void TypedConstant()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new Type[2] {
         typeof(int),
         typeof(string)
     });
 }
Exemple #3
0
        public void Strings()
        {
            int    i = 1;
            string x = "X";

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((("a\n\\b" ?? x) + x).Length == 2) ? false : (true && (1m + (decimal)(-i) > 0m || false)));
        }
Exemple #4
0
 public void AnonymousClasses()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new {
         X = 3,
         A = "a"
     });
 }
Exemple #5
0
 public void ListInitializer3()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new List <int> {
         1,
         2,
         3
     }.Count == 3);
 }
Exemple #6
0
 public void ArrayIndex()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (new int[3] {
         3,
         4,
         5
     })[0 + (int)(DateTime.Now.Ticks % 3)]);
 }
Exemple #7
0
 public void MethodGroupAsExtensionMethod()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), (Expression <Func <Func <bool> > >)(() => ((IEnumerable <int>) new int[4] {
         2000,
         2004,
         2008,
         2012
     }).Any <int>));
 }
Exemple #8
0
 public void QuotedWithAnonymous()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (from o in new[] {
         new {
             X = "a",
             Y = "b"
         }
     }
                                                        select o.X + o.Y).Single());
 }
Exemple #9
0
        public void NotOperator()
        {
            bool x = true;
            int  y = 3;
            byte z = 42;

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => ~z == 0);
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => ~y == 0);
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => !x);
        }
Exemple #10
0
 public void MembersDefault()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => default(DateTime).Ticks == 0);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Array)null).Length == 0);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Type)null).IsLayoutSequential);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((List <int>)null).Count);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Array)null).Clone() == null);
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Type)null).IsInstanceOfType(new object()));
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((List <int>)null).AsReadOnly());
 }
Exemple #11
0
        public void NestedLambda2()
        {
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((string x) => x == "a"));
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((string x) => x != "a"));
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((Action x) => x == new Action(this.NestedLambda2)));
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((Action x) => x != new Action(this.NestedLambda2)));
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((int x) => x == 37));

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Fizz((int x) => true));
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.Buzz((int x) => true));
        }
Exemple #12
0
 public void ArrayLengthAndDoubles()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new double[3] {
         1.0,
         2.01,
         3.5
     }.Concat(new double[2] {
         1.0,
         2.0
     }).ToArray().Length);
 }
Exemple #13
0
        public void ObjectInitializers()
        {
            XmlReaderSettings s = new XmlReaderSettings {
                CloseInput      = false,
                CheckCharacters = false
            };

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => new XmlReaderSettings {
                CloseInput      = s.CloseInput,
                CheckCharacters = s.CheckCharacters
            }.Equals(s));
        }
Exemple #14
0
 public void NewArrayAndExtensionMethod()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new double[3] {
         1.0,
         2.01,
         3.5
     }.SequenceEqual(new double[3] {
         1.0,
         2.01,
         3.5
     }));
 }
Exemple #15
0
 public void ListInitializer()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new Dictionary <int, int> {
         {
             1,
             1
         },
         {
             2,
             2
         },
         {
             3,
             4
         }
     }.Count == 3);
 }
Exemple #16
0
        public void NestedLambda()
        {
            Func <Func <int>, int> call = (Func <int> f) => f();

            //no params
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => call(() => 42));
            //one param
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => from x in new int[2] {
                37,
                42
            }
                                   select x * 2);
            //two params
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => new int[2] {
                37,
                42
            }.Select((int x, int i) => x * 2));
        }
Exemple #17
0
        public void MethodGroupConstant()
        {
            ExpressionTrees.ToCode(ExpressionTrees.X(), () => Array.TrueForAll(new int[4] {
                2000,
                2004,
                2008,
                2012
            }, DateTime.IsLeapYear));

            HashSet <int> set = new HashSet <int>();

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => new int[4] {
                2000,
                2004,
                2008,
                2012
            }.All(set.Add));

            Func <Func <object, object, bool>, bool> sink = (Func <object, object, bool> f) => f(null, null);

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => sink(object.Equals));
        }
Exemple #18
0
 public void StaticCallImplicitCast()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => object.Equals(3, 0));
 }
Exemple #19
0
 public void AddOperator(int x)
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 1 + x + 2);
 }
Exemple #20
0
 public void LambdaParameter()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), (bool a) => a);
 }
Exemple #21
0
        public void LocalVariable()
        {
            bool a = true;

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => a);
        }
Exemple #22
0
 public void Parameter(bool a)
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => a);
 }
Exemple #23
0
 public void InvokeGenericMethod()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => GenericClass <int> .GenericMethod <double>());
 }
Exemple #24
0
 public void GenericClassStatic()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (double)GenericClass <int> .StaticField + GenericClass <double> .StaticProperty);
 }
Exemple #25
0
 public void GenericClassInstance()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (double)new GenericClass <int>().InstanceField + new GenericClass <double>().InstanceProperty);
 }
Exemple #26
0
 public void Quoted()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (Expression <Func <int, string, string> >)((int n, string s) => s + n.ToString()) != null);
 }
Exemple #27
0
 public void StaticMembers()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (DateTime.Now > DateTime.Now + TimeSpan.FromMilliseconds(10.001)).ToString() == "False");
 }
Exemple #28
0
 public void Quoted2()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ExpressionTrees.ToCode(ExpressionTrees.X(), () => true).Equals(null));
 }
Exemple #29
0
 public void ThisExplicit()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => object.Equals(this, 3));
 }
Exemple #30
0
 public void ThisCall()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => !this.Equals(3));
 }