Skip to content

Commit 29f30a1

Browse files
authored
Merge pull request #8955 from hvitved/csharp/useless-cast-fp
C#: Add FP test for `cs/useless-cast-to-self`
2 parents b2e9555 + a0e003e commit 29f30a1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void f()
2222
var good7 = (Action<int>)((int x) => { });
2323
func = x => x;
2424
exprFunc = x => x;
25+
exprFuncUntyped = (Expression<Func<int, int?>>)(x => x); // FP
2526
}
2627

2728
enum Enum
@@ -35,4 +36,5 @@ enum Enum
3536

3637
private Func<int, int?> func;
3738
private Expression<Func<int, int?>> exprFunc;
39+
private LambdaExpression exprFuncUntyped;
3840
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
| UselessCastToSelf.cs:10:20:10:29 | (...) ... | This cast is redundant because the expression already has type Test. |
33
| UselessCastToSelf.cs:11:20:11:31 | ... as ... | This cast is redundant because the expression already has type Test. |
44
| UselessCastToSelf.cs:13:20:13:56 | (...) ... | This cast is redundant because the expression already has type Expression<Func<Int32,Nullable<Int32>>>. |
5-
| UselessCastToSelf.cs:31:17:31:22 | (...) ... | This cast is redundant because the expression already has type Int32. |
6-
| UselessCastToSelf.cs:33:24:33:29 | (...) ... | This cast is redundant because the expression already has type Int32. |
5+
| UselessCastToSelf.cs:25:27:25:63 | (...) ... | This cast is redundant because the expression already has type Expression<Func<Int32,Nullable<Int32>>>. |
6+
| UselessCastToSelf.cs:32:17:32:22 | (...) ... | This cast is redundant because the expression already has type Int32. |
7+
| UselessCastToSelf.cs:34:24:34:29 | (...) ... | This cast is redundant because the expression already has type Int32. |

0 commit comments

Comments
 (0)