Skip to content

Commit 50570dc

Browse files
committed
C#: Only add explicit interface implementation to the generated stub if it is unique.
1 parent 5ba59fc commit 50570dc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private string stubAccessibility(Member m) {
400400
if
401401
m.getDeclaringType() instanceof Interface
402402
or
403-
exists(m.(Virtualizable).getExplicitlyImplementedInterface())
403+
exists(getSingleSpecificImplementedInterface(m))
404404
or
405405
m instanceof Constructor and m.isStatic()
406406
then result = ""
@@ -713,9 +713,13 @@ private string stubEventAccessors(Event e) {
713713
else result = ";"
714714
}
715715

716+
private Interface getSingleSpecificImplementedInterface(Member c) {
717+
result = unique(Interface i | i = c.(Virtualizable).getExplicitlyImplementedInterface())
718+
}
719+
716720
private string stubExplicitImplementation(Member c) {
717-
if exists(c.(Virtualizable).getExplicitlyImplementedInterface())
718-
then result = stubClassName(c.(Virtualizable).getExplicitlyImplementedInterface()) + "."
721+
if exists(getSingleSpecificImplementedInterface(c))
722+
then result = stubClassName(getSingleSpecificImplementedInterface(c)) + "."
719723
else result = ""
720724
}
721725

0 commit comments

Comments
 (0)