Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Adding synthetic implicit ToString calls in binary- and string interpolation expressions. #18446

Merged
merged 22 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
261b8db
C#: Add some implicit toString data flow test cases.
michaelnebel Jan 8, 2025
f905be4
C#: Add a RedundantToStringCall test case.
michaelnebel Jan 9, 2025
908a3e3
C#: Make synthetic ToString calls in binary add expressions.
michaelnebel Jan 8, 2025
e9beeac
C#: Update test expected output.
michaelnebel Jan 8, 2025
5f539c5
C#: Make synthetic ToString calls in string interpolation expressions.
michaelnebel Jan 10, 2025
8bf67e3
C#: Update test expected output.
michaelnebel Jan 10, 2025
a4049b1
C#: Modify compiler generated strip logic to also take generated ToSt…
michaelnebel Jan 9, 2025
6c6e58b
C#: Add PrintAst test to implicit ToString test.
michaelnebel Jan 9, 2025
53c2f76
C#: Update AST printing to include generated cast (wrapping) expressi…
michaelnebel Jan 9, 2025
f239ab1
C#: Update PrintAst expected test output.
michaelnebel Jan 9, 2025
20c2b2b
C#: Update other existing tests expected output.
michaelnebel Jan 9, 2025
cd7d2d4
C#: Add change note.
michaelnebel Jan 9, 2025
6a31fd7
C#: Add ImplicitToString example in nullness tests.
michaelnebel Jan 13, 2025
e62846e
C#: Disregard compiler generated method calls as possible null derefe…
michaelnebel Jan 13, 2025
d40c1be
C#: Update expected testoutput for Nullness tests.
michaelnebel Jan 13, 2025
77f9f4c
C#: Add implicit to string usage in constructor.
michaelnebel Jan 13, 2025
2bff2d6
C#: Disregards compiler generated virtual calls as problematic virtua…
michaelnebel Jan 13, 2025
024de5e
C#: Update virtual call in constructor expected test output.
michaelnebel Jan 13, 2025
ab70a94
C#: Add a summary model for PathString.ToString.
michaelnebel Jan 13, 2025
6a406b2
C#: Do not insert a synthetic ToString call in interpolation expressi…
michaelnebel Jan 14, 2025
0c5c2a3
C#: Add implicit to string test.
michaelnebel Jan 14, 2025
3de5b22
C#: Update other existing tests expected output.
michaelnebel Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
C#: Add ImplicitToString example in nullness tests.
michaelnebel committed Jan 14, 2025
commit 6a31fd7893f4743e631db302d9add41988a57d68
2 changes: 2 additions & 0 deletions csharp/ql/test/query-tests/Nullness/Implications.expected
Original file line number Diff line number Diff line change
@@ -1451,6 +1451,8 @@
| GuardedString.cs:35:31:35:31 | access to local variable s | null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | null |
| GuardedString.cs:37:31:37:31 | access to local variable s | non-null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | non-null |
| GuardedString.cs:37:31:37:31 | access to local variable s | null | GuardedString.cs:7:20:7:32 | ... ? ... : ... | null |
| ImplicitToString.cs:8:23:8:23 | access to local variable o | non-null | ImplicitToString.cs:7:20:7:23 | null | non-null |
| ImplicitToString.cs:8:23:8:23 | access to local variable o | null | ImplicitToString.cs:7:20:7:23 | null | null |
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | false | NullAlwaysBad.cs:9:17:9:17 | access to parameter s | null |
| NullAlwaysBad.cs:9:17:9:25 | ... != ... | true | NullAlwaysBad.cs:9:17:9:17 | access to parameter s | non-null |
| NullAlwaysBad.cs:9:17:9:41 | ... \|\| ... | false | NullAlwaysBad.cs:9:17:9:25 | ... != ... | false |
10 changes: 10 additions & 0 deletions csharp/ql/test/query-tests/Nullness/ImplicitToString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

class ImplicitToStringTest
{
void InterpolatedStringImplicitToString()
{
object o = null;
string s = $"{o}"; // GOOD
}
}
1 change: 1 addition & 0 deletions csharp/ql/test/query-tests/Nullness/NullAlways.expected
Original file line number Diff line number Diff line change
@@ -40,4 +40,5 @@
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
3 changes: 3 additions & 0 deletions csharp/ql/test/query-tests/Nullness/NullMaybe.expected
Original file line number Diff line number Diff line change
@@ -443,6 +443,8 @@ nodes
| GuardedString.cs:34:9:37:40 | if (...) ... |
| GuardedString.cs:34:26:34:26 | 0 |
| GuardedString.cs:35:31:35:31 | access to local variable s |
| ImplicitToString.cs:7:16:7:23 | SSA def(o) |
| ImplicitToString.cs:8:23:8:23 | access to local variable o |
| NullAlwaysBad.cs:7:29:7:29 | SSA param(s) |
| NullAlwaysBad.cs:9:30:9:30 | access to parameter s |
| NullMaybeBad.cs:7:27:7:27 | access to parameter o |
@@ -837,6 +839,7 @@ edges
| GuardedString.cs:31:26:31:27 | 10 | GuardedString.cs:34:9:37:40 | if (...) ... |
| GuardedString.cs:34:9:37:40 | if (...) ... | GuardedString.cs:34:26:34:26 | 0 |
| GuardedString.cs:34:26:34:26 | 0 | GuardedString.cs:35:31:35:31 | access to local variable s |
| ImplicitToString.cs:7:16:7:23 | SSA def(o) | ImplicitToString.cs:8:23:8:23 | access to local variable o |
| NullAlwaysBad.cs:7:29:7:29 | SSA param(s) | NullAlwaysBad.cs:9:30:9:30 | access to parameter s |
| NullMaybeBad.cs:13:17:13:20 | null | NullMaybeBad.cs:7:27:7:27 | access to parameter o |
| Params.cs:20:12:20:15 | null | Params.cs:14:17:14:20 | access to parameter args |