[interp] Reduce computation under calc_section mutex
[mono-project.git] / mcs / tests / dtest-null-operator-01.cs
blobde6013ca044e383a23df3a7b1af1fbd577431d27
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
5 class X
7 public string Prop;
8 public A A = new A ();
11 class A
13 public string B;
16 class MainClass
18 static void NullCheckTest ()
20 dynamic dyn = null;
21 dynamic res;
23 res = dyn?.ToString ();
24 res = dyn?.GetHashCode ();
25 res = dyn?.DD.Length?.GetHashCode ();
27 dyn?.ToString ();
29 res = dyn?.Prop;
30 res = dyn?.Prop?.Prop2;
31 res = dyn?[0];
34 static void Test_1 ()
36 dynamic dyn = new X ();
37 dynamic res;
39 res = dyn.Prop?.Length;
40 res = dyn.A.B?.C.D?.E.F;
43 static dynamic Test_2 (IEnumerable<dynamic> collection)
45 return collection?.FirstOrDefault ().Length;
48 public static void Main ()
50 NullCheckTest ();
52 Test_1 ();
53 Test_2 (null);