mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
23 lines
543 B
C#
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;
|
|
}
|
|
}
|