Skip to content

Commit 2bff2d6

Browse files
committed
C#: Disregards compiler generated virtual calls as problematic virtual calls.
1 parent 77f9f4c commit 2bff2d6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

csharp/ql/src/Bad Practices/VirtualCallInConstructorOrDestructor.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ predicate overriddenSealed(RefType t, Virtualizable d) {
3434
}
3535

3636
predicate virtualAccessWithThisQualifier(Expr e, Member d) {
37-
exists(VirtualMethodCall c | c = e and c.getTarget() = d and c.hasThisQualifier())
37+
exists(VirtualMethodCall c |
38+
c = e and c.getTarget() = d and c.hasThisQualifier() and not c.isImplicit()
39+
)
3840
or
3941
exists(VirtualMethodAccess c | c = e and c.getTarget() = d and c.hasThisQualifier())
4042
or

0 commit comments

Comments
 (0)