Files
codeql/csharp/ql/test/query-tests/Nullness/StringConcatenation.cs
Tom Hvitved d2a431e6f3 C#: Add more nullness tests
Port many of the nullness test from Java, as well as add new tests.
2018-11-30 17:02:05 +01:00

34 lines
539 B
C#

using System;
class StringsTest
{
void StringAdded()
{
string s = null;
s += "abc";
s = s.Trim(); // GOOD
}
void StringMaybeNull()
{
string s = null;
while (s != "")
s = s.Trim(); // BAD (maybe)
}
void StringNotNull()
{
string s = null;
while (s != "")
s += "abc";
s = s.Trim(); // GOOD
}
void StringNotAssignedNull()
{
string s = "abc";
s += null;
s = s.Trim(); // GOOD
}
}