зеркало из https://github.com/github/codeql.git
C#: Add more tests for `cs/constant-condition`
This commit is contained in:
Родитель
fad37bd6c9
Коммит
4da7a17f4b
|
@ -1,4 +1,4 @@
|
||||||
// semmle-extractor-options: /r:System.Threading.Thread.dll /r:System.Diagnostics.Debug.dll
|
// semmle-extractor-options: /r:System.Threading.Thread.dll /r:System.Diagnostics.Debug.dll /langversion:preview
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
@ -89,6 +89,23 @@ class ConstantMatching
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string M4(object o)
|
||||||
|
{
|
||||||
|
return o switch
|
||||||
|
{
|
||||||
|
_ => o.ToString() // BAD
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
string M5(object o)
|
||||||
|
{
|
||||||
|
return o switch
|
||||||
|
{
|
||||||
|
"" => " ",
|
||||||
|
_ => o.ToString() // GOOD
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Assertions
|
class Assertions
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
| ConstantCondition.cs:64:18:64:18 | 2 | Pattern never matches. |
|
| ConstantCondition.cs:64:18:64:18 | 2 | Pattern never matches. |
|
||||||
| ConstantCondition.cs:66:18:66:18 | 3 | Pattern always matches. |
|
| ConstantCondition.cs:66:18:66:18 | 3 | Pattern always matches. |
|
||||||
| ConstantCondition.cs:77:18:77:20 | access to type Int32 | Pattern never matches. |
|
| ConstantCondition.cs:77:18:77:20 | access to type Int32 | Pattern never matches. |
|
||||||
|
| ConstantCondition.cs:97:13:97:13 | _ | Pattern always matches. |
|
||||||
|
| ConstantCondition.cs:106:13:106:13 | _ | Pattern always matches. |
|
||||||
| ConstantConditionBad.cs:5:16:5:20 | ... > ... | Condition always evaluates to 'false'. |
|
| ConstantConditionBad.cs:5:16:5:20 | ... > ... | Condition always evaluates to 'false'. |
|
||||||
| ConstantConditionalExpressionCondition.cs:11:22:11:34 | ... == ... | Condition always evaluates to 'true'. |
|
| ConstantConditionalExpressionCondition.cs:11:22:11:34 | ... == ... | Condition always evaluates to 'true'. |
|
||||||
| ConstantConditionalExpressionCondition.cs:12:21:12:25 | false | Condition always evaluates to 'false'. |
|
| ConstantConditionalExpressionCondition.cs:12:21:12:25 | false | Condition always evaluates to 'false'. |
|
||||||
|
|
Загрузка…
Ссылка в новой задаче