Files
codeql/csharp/ql/test/query-tests/standalone/ObjectComparison/ObjectComparison.cs
2021-07-01 16:09:11 +02:00

23 lines
543 B
C#

class ObjectComparisonTest
{
UnknownType unknownValue;
void test()
{
bool result;
// GOOD: type information missing
result = unknownF() == unknownF();
result = this == unknownValue;
result = someValue == unknownValue;
result = (object)unknownF() == 0;
result = (object)unknownValue = someValue;
// BAD: Explicit cast
result = (object)unknownValue == (object)someValue;
// BAD: Type information known
result = this == (object)this;
}
}