Merge pull request #2773 from hvitved/csharp/useless-assignment-to-local-default

C#: Remove false positives for `cs/useless-assignment-to-local`
This commit is contained in:
Calum Grant
2020-02-07 10:37:19 +00:00
committed by GitHub
3 changed files with 16 additions and 1 deletions

View File

@@ -114,7 +114,7 @@ class RelevantDefinition extends AssignableDefinition {
*/
private predicate isDefaultLikeInitializer() {
this.isInitializer() and
exists(Expr e | e = this.getSource() |
exists(Expr e | e = this.getSource().stripCasts() |
exists(string val | val = e.getValue() |
val = "0" or
val = "-1" or

View File

@@ -389,6 +389,20 @@ class Initializers
return s;
return null;
}
string M8()
{
string s = default; // "GOOD"
s = "";
return s;
}
string M9()
{
var s = (string)null; // "GOOD"
s = "";
return s;
}
}
class Anonymous