Skip to content

Commit a635503

Browse files
committed
Add test cases to UselessCastToSelf
1 parent 3577b27 commit a635503

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

csharp/ql/test/query-tests/Language Abuse/UselessCastToSelf/UselessCastToSelf.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ void f()
1818
var good6 = (Action<int>)(delegate (int x) { });
1919
var good7 = (Action<int>)((int x) => { });
2020
}
21+
22+
enum Enum
23+
{
24+
A = 2,
25+
B = 1 | A,
26+
C = 1 | (int)A, // BAD
27+
D = 9 | (32 << A),
28+
E = 9 | (32 << (int)A) // BAD
29+
}
2130
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
| UselessCastToSelf.cs:8:20:8:25 | (...) ... | This cast is redundant because the expression already has type Int32. |
22
| UselessCastToSelf.cs:9:20:9:29 | (...) ... | This cast is redundant because the expression already has type Test. |
33
| UselessCastToSelf.cs:10:20:10:31 | ... as ... | This cast is redundant because the expression already has type Test. |
4+
| UselessCastToSelf.cs:26:17:26:22 | (...) ... | This cast is redundant because the expression already has type Int32. |
5+
| UselessCastToSelf.cs:28:24:28:29 | (...) ... | This cast is redundant because the expression already has type Int32. |

0 commit comments

Comments
 (0)