Skip to content

Commit 81904cc

Browse files
committed
C#: Refactor isIrrelevantOverrideOrImplementation to make it easier to extend it with more methods later.
1 parent 5cb2bd9 commit 81904cc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

csharp/ql/src/utils/model-generator/internal/CaptureModelsSpecific.qll

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ class Type = CS::Type;
2222
* is irrelevant to the data flow analysis.
2323
*/
2424
private predicate isIrrelevantOverrideOrImplementation(CS::Callable api) {
25-
exists(System::SystemObjectClass c |
26-
api = c.getGetHashCodeMethod().getAnOverrider*() or
27-
api = c.getEqualsMethod().getAnOverrider*()
25+
exists(CS::Callable exclude, CS::Method m |
26+
(
27+
api = m.getAnOverrider*().getUnboundDeclaration()
28+
or
29+
api = m.getAnUltimateImplementor().getUnboundDeclaration()
30+
) and
31+
exclude = m.getUnboundDeclaration()
32+
|
33+
exists(System::SystemObjectClass c | exclude = [c.getGetHashCodeMethod(), c.getEqualsMethod()])
34+
or
35+
exists(System::SystemIEquatableTInterface i | exclude = i.getEqualsMethod())
2836
)
29-
or
30-
exists(System::IEquatableEqualsMethod equals | equals = api)
3137
}
3238

3339
/**

0 commit comments

Comments
 (0)