mirror of
https://github.com/github/codeql.git
synced 2026-05-04 21:25:44 +02:00
C#: Add more nullness tests
Port many of the nullness test from Java, as well as add new tests.
This commit is contained in:
@@ -6,14 +6,14 @@ class StringsTest
|
||||
{
|
||||
string s = null;
|
||||
s += "abc";
|
||||
s = s.Trim(); // OK
|
||||
s = s.Trim(); // GOOD
|
||||
}
|
||||
|
||||
void StringMaybeNull()
|
||||
{
|
||||
string s = null;
|
||||
while (s != "")
|
||||
s = s.Trim(); // Maybe null
|
||||
s = s.Trim(); // BAD (maybe)
|
||||
}
|
||||
|
||||
void StringNotNull()
|
||||
@@ -21,13 +21,13 @@ class StringsTest
|
||||
string s = null;
|
||||
while (s != "")
|
||||
s += "abc";
|
||||
s = s.Trim(); // OK (s == "")
|
||||
s = s.Trim(); // GOOD
|
||||
}
|
||||
|
||||
void StringNotAssignedNull()
|
||||
{
|
||||
string s = "abc";
|
||||
s += null;
|
||||
s = s.Trim(); // OK
|
||||
s = s.Trim(); // GOOD
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user