You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
57
mcs/tests/dtest-null-operator-01.cs
Normal file
57
mcs/tests/dtest-null-operator-01.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
class X
|
||||
{
|
||||
public string Prop;
|
||||
public A A = new A ();
|
||||
}
|
||||
|
||||
class A
|
||||
{
|
||||
public string B;
|
||||
}
|
||||
|
||||
class MainClass
|
||||
{
|
||||
static void NullCheckTest ()
|
||||
{
|
||||
dynamic dyn = null;
|
||||
dynamic res;
|
||||
|
||||
res = dyn?.ToString ();
|
||||
res = dyn?.GetHashCode ();
|
||||
res = dyn?.DD.Length?.GetHashCode ();
|
||||
|
||||
dyn?.ToString ();
|
||||
|
||||
res = dyn?.Prop;
|
||||
res = dyn?.Prop?.Prop2;
|
||||
res = dyn?[0];
|
||||
}
|
||||
|
||||
static void Test_1 ()
|
||||
{
|
||||
dynamic dyn = new X ();
|
||||
dynamic res;
|
||||
|
||||
res = dyn.Prop?.Length;
|
||||
res = dyn.A.B?.C.D?.E.F;
|
||||
}
|
||||
|
||||
static dynamic Test_2 (IEnumerable<dynamic> collection)
|
||||
{
|
||||
return collection?.FirstOrDefault ().Length;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
NullCheckTest ();
|
||||
|
||||
Test_1 ();
|
||||
Test_2 (null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user