Skip to content

Commit b6f3f78

Browse files
committed
C#: Add more tests for cs/unchecked-return-value
1 parent a1b4d09 commit b6f3f78

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

csharp/ql/test/query-tests/API Abuse/UncheckedReturnValue/UncheckedReturnValue.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,23 @@ class C5 { }
158158
class C6 : C5 { }
159159
class C7 : C6 { }
160160
}
161+
162+
class C5
163+
{
164+
int M1() => 0;
165+
166+
void M2()
167+
{
168+
// GOOD
169+
M1();
170+
Action a = () => M1();
171+
a = () => M1();
172+
a = () => M1();
173+
a = () => M1();
174+
a = () => M1();
175+
a = () => M1();
176+
a = () => M1();
177+
a = () => M1();
178+
a = () => M1();
179+
}
180+
}

csharp/ql/test/query-tests/API Abuse/UncheckedReturnValue/UncheckedReturnValue.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
| UncheckedReturnValue.cs:109:9:109:17 | call to method M1 | Result of call to 'M1' is ignored, but 90% of calls to this method have their result used. |
55
| UncheckedReturnValue.cs:130:9:130:21 | call to method M2 | Result of call to 'M2' is ignored, but 90% of calls to this method have their result used. |
66
| UncheckedReturnValue.cs:142:9:142:20 | call to method M3 | Result of call to 'M3' is ignored, but 90% of calls to this method have their result used. |
7+
| UncheckedReturnValue.cs:169:9:169:12 | call to method M1 | Result of call to 'M1' is ignored, but 90% of calls to this method have their result used. |
78
| UncheckedReturnValueBad.cs:29:9:29:20 | call to method DoPrint | Result of call to 'DoPrint' is ignored, but 90% of calls to this method have their result used. |
89
| UncheckedReturnValueBad.cs:36:13:36:40 | call to method Read | Result of call to 'Read' is ignored, but should always be checked. |

0 commit comments

Comments
 (0)