Skip to content

Commit 6a31fd7

Browse files
committed
C#: Add ImplicitToString example in nullness tests.
1 parent cd7d2d4 commit 6a31fd7

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

csharp/ql/test/query-tests/Nullness/Implications.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,8 @@
14511451
| GuardedString.cs:35:31:35:31 | access to local variable s | null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | null |
14521452
| GuardedString.cs:37:31:37:31 | access to local variable s | non-null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | non-null |
14531453
| GuardedString.cs:37:31:37:31 | access to local variable s | null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | null |
1454+
| ImplicitToString.cs:8:23:8:23 | access to local variable o | non-null | ImplicitToString.cs:7:20:7:23 | null | non-null |
1455+
| ImplicitToString.cs:8:23:8:23 | access to local variable o | null | ImplicitToString.cs:7:20:7:23 | null | null |
14541456
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | false | NullAlwaysBad.cs:9:17:9:17 | access to parameter s | null |
14551457
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | true | NullAlwaysBad.cs:9:17:9:17 | access to parameter s | non-null |
14561458
| NullAlwaysBad.cs:9:17:9:41 | ... \|\| ... | false | NullAlwaysBad.cs:9:17:9:25 | ... != ... | false |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
class ImplicitToStringTest
4+
{
5+
void InterpolatedStringImplicitToString()
6+
{
7+
object o = null;
8+
string s = $"{o}"; // GOOD
9+
}
10+
}

csharp/ql/test/query-tests/Nullness/NullAlways.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@
4040
| E.cs:439:13:439:13 | access to parameter s | Variable $@ is always null at this dereference. | E.cs:435:29:435:29 | s | s |
4141
| Forwarding.cs:36:31:36:31 | access to local variable s | Variable $@ is always null at this dereference. | Forwarding.cs:7:16:7:16 | s | s |
4242
| Forwarding.cs:40:27:40:27 | access to local variable s | Variable $@ is always null at this dereference. | Forwarding.cs:7:16:7:16 | s | s |
43+
| ImplicitToString.cs:8:23:8:23 | access to local variable o | Variable $@ is always null at this dereference. | ImplicitToString.cs:7:16:7:16 | o | o |
4344
| NullAlwaysBad.cs:9:30:9:30 | access to parameter s | Variable $@ is always null at this dereference. | NullAlwaysBad.cs:7:29:7:29 | s | s |

csharp/ql/test/query-tests/Nullness/NullMaybe.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ nodes
443443
| GuardedString.cs:34:9:37:40 | if (...) ... |
444444
| GuardedString.cs:34:26:34:26 | 0 |
445445
| GuardedString.cs:35:31:35:31 | access to local variable s |
446+
| ImplicitToString.cs:7:16:7:23 | SSA def(o) |
447+
| ImplicitToString.cs:8:23:8:23 | access to local variable o |
446448
| NullAlwaysBad.cs:7:29:7:29 | SSA param(s) |
447449
| NullAlwaysBad.cs:9:30:9:30 | access to parameter s |
448450
| NullMaybeBad.cs:7:27:7:27 | access to parameter o |
@@ -837,6 +839,7 @@ edges
837839
| GuardedString.cs:31:26:31:27 | 10 | GuardedString.cs:34:9:37:40 | if (...) ... |
838840
| GuardedString.cs:34:9:37:40 | if (...) ... | GuardedString.cs:34:26:34:26 | 0 |
839841
| GuardedString.cs:34:26:34:26 | 0 | GuardedString.cs:35:31:35:31 | access to local variable s |
842+
| ImplicitToString.cs:7:16:7:23 | SSA def(o) | ImplicitToString.cs:8:23:8:23 | access to local variable o |
840843
| NullAlwaysBad.cs:7:29:7:29 | SSA param(s) | NullAlwaysBad.cs:9:30:9:30 | access to parameter s |
841844
| NullMaybeBad.cs:13:17:13:20 | null | NullMaybeBad.cs:7:27:7:27 | access to parameter o |
842845
| Params.cs:20:12:20:15 | null | Params.cs:14:17:14:20 | access to parameter args |

0 commit comments

Comments
 (0)