[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / tests / fullaot-mixed / lambda.cs
blob83cd242de2b918eb1bcc679a46cb59d7a5bb930c
1 /* This test is extracted from System.Core tests, that happens to be
2 * problematic if *all* assemblies are full-aot'd, but the interpreter is still
3 * used for SRE.
4 */
5 using System;
6 using System.Collections.Generic;
7 using System.Reflection;
8 using System.Linq;
9 using System.Linq.Expressions;
11 public class Repro {
12 public class Foo {
13 public string Bar;
14 public string Baz;
16 public Gazonk Gaz;
18 public Gazonk Gazoo { get; set; }
20 public string Gruik { get; set; }
22 public Foo ()
24 Gazoo = new Gazonk ();
25 Gaz = new Gazonk ();
29 public class Gazonk {
30 public string Tzap;
32 public int Klang;
34 public string Couic { get; set; }
36 public string Bang () { return ""; }
39 public static int CompiledMemberBinding ()
41 var getfoo = Expression.Lambda<Func<Foo>> (
42 Expression.MemberInit (
43 Expression.New (typeof (Foo)),
44 Expression.MemberBind (
45 typeof (Foo).GetProperty ("Gazoo"),
46 Expression.Bind (typeof (Gazonk).GetField ("Tzap"),
47 Expression.Constant ("tzap")),
48 Expression.Bind (typeof (Gazonk).GetField ("Klang"),
49 Expression.Constant (42))))).Compile ();
51 var foo = getfoo ();
53 if (foo == null)
54 return 2;
55 if (foo.Gazoo.Klang != 42)
56 return 3;
57 if (foo.Gazoo.Tzap != "tzap")
58 return 4;
60 return 0;
63 public static int Main (string []args)
65 return CompiledMemberBinding ();