Skip to content

Commit 5eb305d

Browse files
committed
C#: Add some value tuple examples for cs/call-to-object-tostring and update test expected output.
1 parent 08913c5 commit 5eb305d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

csharp/ql/test/query-tests/Useless Code/DefaultToString/DefaultToString.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ void M()
3535

3636
IPublic g = null;
3737
Console.WriteLine(g); // GOOD
38+
39+
Console.WriteLine(new ValueTuple<int, int>(1, 2)); // GOOD [FALSE POSITIVE]
40+
41+
Console.WriteLine((1, 2)); // GOOD [FALSE POSITIVE]
42+
43+
var t1 = new ValueTuple<int, DefaultToString>(1, new DefaultToString());
44+
Console.WriteLine(t1); // BAD
45+
46+
var t2 = new ValueTuple<A, D>(new A(), new D());
47+
Console.WriteLine(t2); // GOOD [FALSE POSITIVE]
3848
}
3949

4050
class A

csharp/ql/test/query-tests/Useless Code/DefaultToString/DefaultToString.expected

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
| DefaultToString.cs:10:28:10:28 | access to local variable d | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | DefaultToString.cs:4:14:4:28 | DefaultToString | DefaultToString |
33
| DefaultToString.cs:16:27:16:30 | access to local variable ints | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | Int32[] | Int32[] |
44
| DefaultToString.cs:19:24:19:27 | access to local variable ints | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | Int32[] | Int32[] |
5-
| DefaultToString.cs:34:27:34:27 | access to local variable f | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | DefaultToString.cs:62:23:62:30 | IPrivate | IPrivate |
5+
| DefaultToString.cs:34:27:34:27 | access to local variable f | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | DefaultToString.cs:72:23:72:30 | IPrivate | IPrivate |
6+
| DefaultToString.cs:39:27:39:56 | (...) ... | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | (Int32,Int32) | (Int32,Int32) |
7+
| DefaultToString.cs:41:27:41:32 | (...) ... | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | (Int32,Int32) | (Int32,Int32) |
8+
| DefaultToString.cs:44:27:44:28 | (...) ... | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | (Int32,DefaultToString) | (Int32,DefaultToString) |
9+
| DefaultToString.cs:47:27:47:28 | (...) ... | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | (A,D) | (A,D) |
610
| DefaultToStringBad.cs:8:35:8:35 | access to local variable p | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | DefaultToStringBad.cs:14:11:14:16 | Person | Person |
711
| DefaultToStringBad.cs:11:38:11:41 | access to local variable ints | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | Int32[] | Int32[] |
812
| WriteLineArray.cs:7:23:7:26 | access to parameter args | Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing. | file://:0:0:0:0 | String[] | String[] |

0 commit comments

Comments
 (0)