Skip to content

Commit 576085a

Browse files
committed
Add extra information to nullable conversion test file
1 parent faf663a commit 576085a

File tree

1 file changed

+28
-4
lines changed
  • csharp/ql/test/library-tests/conversion/nullable

1 file changed

+28
-4
lines changed
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
using System;
2+
using System.Runtime.Serialization;
23

34
class C
45
{
5-
sbyte x1;
6-
sbyte? x2;
6+
int x1;
7+
int? x2;
78
Nullable<int> x3;
89
Nullable<char> x4;
910

1011
// Verify conversions
1112
void M()
1213
{
13-
x2 = x1;
14-
x3 = x4;
14+
x2 = x1; // T -> T? conversion: implicit, nullable -> implicit cast
15+
x3 = x4; // T1? -> T2? conversion: implicit, nullable -> implicit cast
16+
17+
x12 = x1; // T1 -> T2? conversion: implicit, nullable -> implicit cast
18+
x12 = null; // null -> T? conversion: implicit, null literal -> no cast
19+
20+
x3 = x2; // T? -> T? no conversion
21+
22+
x14 = x15; // T1? -> T2? conversion: implicit, user defined -> implicit cast
1523
}
1624

1725
// Cause the following types to exist in the database:
26+
sbyte? x0;
1827
byte? x5;
1928
short? x6;
2029
ushort? x7;
@@ -24,4 +33,19 @@ void M()
2433
double? x11;
2534
long? x12;
2635
float? x13;
36+
37+
A? x14;
38+
B? x15;
39+
40+
struct A
41+
{
42+
}
43+
44+
struct B
45+
{
46+
public static implicit operator A(B value)
47+
{
48+
return new A();
49+
}
50+
}
2751
}

0 commit comments

Comments
 (0)