[tests] Test loading references from LoadFrom and LoadFile contexts
[mono-project.git] / mono / tests / delegate-prop.cs
blob280926b266e945272e2cbc97cc1e1f0f7b3ef79d
1 using System;
2 using System.Reflection;
3 using System.Globalization;
4 using System.Diagnostics;
6 /* Regression test for https://github.com/mono/mono/issues/7944 */
7 public class MyClass
9 public string Prop1 { get; set; }
10 public string Prop2 { get; set; }
12 public void DoRepro()
14 var prop1Setter = this.GetType ().GetProperty (nameof (Prop1)).GetSetMethod ();
15 var prop2Setter = this.GetType ().GetProperty (nameof (Prop2)).GetSetMethod ();
16 var prop1Delegate = (Action <MyClass, string>) prop1Setter.CreateDelegate(typeof (Action <MyClass, string>));
17 var prop2Delegate = (Action <MyClass, string>) prop2Setter.CreateDelegate(typeof (Action <MyClass, string>));
18 prop1Delegate (this, "prop1Value");
19 prop2Delegate (this, "prop2Value");
21 // Console.WriteLine ($"prop1: {Prop1}");
22 // Console.WriteLine ($"prop2: {Prop2}");
25 public static int Main (string []args) {
26 var o = new MyClass ();
27 o.DoRepro ();
29 if (o.Prop1 != "prop1Value")
30 return 1;
32 if (o.Prop2 != "prop2Value")
33 return 2;
35 return 0;