Skip to content

Commit a8a8b03

Browse files
Jami CogswellJami Cogswell
authored andcommitted
C#: exclude parameterless constructors from DataFlowTargetApi
1 parent 16d8e8e commit a8a8b03

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ private predicate isHigherOrder(CS::Callable api) {
3030
)
3131
}
3232

33+
/** Holds if the given API is a constructor without parameters. */
34+
private predicate isParameterlessConstructor(CS::Callable api) {
35+
api instanceof CS::Constructor and api.getNumberOfParameters() = 0
36+
}
37+
3338
/**
3439
* Holds if it is relevant to generate models for `api`.
3540
*/
@@ -38,7 +43,8 @@ private predicate isRelevantForModels(CS::Callable api) {
3843
api.getDeclaringType().getNamespace().getFullName() != "" and
3944
not api instanceof CS::ConversionOperator and
4045
not api instanceof Util::MainMethod and
41-
not api instanceof CS::Destructor
46+
not api instanceof CS::Destructor and
47+
not isParameterlessConstructor(api)
4248
}
4349

4450
/**

0 commit comments

Comments
 (0)