diff --git a/csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll b/csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll index 3e1a303d5bb..d08a3e03805 100644 --- a/csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll +++ b/csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll @@ -30,6 +30,11 @@ private predicate isHigherOrder(CS::Callable api) { ) } +/** Holds if the given API is a constructor without parameters. */ +private predicate isParameterlessConstructor(CS::Callable api) { + api instanceof CS::Constructor and api.getNumberOfParameters() = 0 +} + /** * Holds if it is relevant to generate models for `api`. */ @@ -38,7 +43,8 @@ private predicate isRelevantForModels(CS::Callable api) { api.getDeclaringType().getNamespace().getFullName() != "" and not api instanceof CS::ConversionOperator and not api instanceof Util::MainMethod and - not api instanceof CS::Destructor + not api instanceof CS::Destructor and + not isParameterlessConstructor(api) } /**