Skip to content

Commit 87bb4a1

Browse files
committed
C#: Add null guard test involving GetType()
1 parent d776d9f commit 87bb4a1

File tree

1 file changed

+8
-0
lines changed
  • csharp/ql/test/library-tests/controlflow/guards

1 file changed

+8
-0
lines changed

csharp/ql/test/library-tests/controlflow/guards/Guards.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,12 @@ void M21(bool b)
262262
return;
263263
}
264264
}
265+
266+
void M22(object o1, object o2)
267+
{
268+
if (o1?.GetType() == o2.GetType())
269+
o1.ToString(); // null guarded
270+
if (o1?.GetType() == o2?.GetType())
271+
o1.ToString(); // not null guarded
272+
}
265273
}

0 commit comments

Comments
 (0)