1 // Compiler options: -unsafe
4 using System
.Linq
.Expressions
;
6 delegate void EmptyDelegate ();
7 unsafe delegate int* UnsafeDelegate ();
18 static unsafe int* Foo ()
29 Expression
<Func
<EmptyDelegate
>> e
= () => M
;
30 if (e
.Body
.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, value(C)))")
35 Expression
<Func
<C
, EmptyDelegate
>> e2
= (l
) => l
.M
;
36 if (e2
.Body
.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, l))")
43 public static int Main ()
45 Expression
<Func
<EmptyDelegate
>> e
= () => new EmptyDelegate (Test
);
46 if (e
.Body
.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
55 Expression
<Func
<EmptyDelegate
>> e2
= () => Test
;
56 if (e2
.Body
.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))")
59 var v2
= e2
.Compile ();
66 Expression
<Func
<UnsafeDelegate
>> e3
= () => new UnsafeDelegate (Foo
);
67 if (e3
.Body
.ToString () != "Convert(Int32* Foo().CreateDelegate(UnsafeDelegate, null))")
70 var v3
= e3
.Compile ();
71 if (v3
.Invoke ()() != (int*)1)
75 if (new C ().TestInstance () != 0)
78 Console
.WriteLine ("OK");