Skip to content

Commit 39154b1

Browse files
Jami CogswellJami Cogswell
authored andcommitted
C#: add isParameterless predicate to Constructor class
1 parent 5113041 commit 39154b1

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

csharp/ql/lib/semmle/code/csharp/Callable.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ class Constructor extends DotNet::Constructor, Callable, Member, Attributable, @
358358
if this.isStatic() then result = this.getParameter(i) else result = this.getParameter(i - 1)
359359
}
360360

361+
/** Holds if this is a constructor without parameters. */
362+
predicate isParameterless() { this.getNumberOfParameters() = 0 }
363+
361364
override string getUndecoratedName() { result = ".ctor" }
362365
}
363366

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ 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-
3833
/**
3934
* Holds if it is relevant to generate models for `api`.
4035
*/
@@ -44,7 +39,7 @@ private predicate isRelevantForModels(CS::Callable api) {
4439
not api instanceof CS::ConversionOperator and
4540
not api instanceof Util::MainMethod and
4641
not api instanceof CS::Destructor and
47-
not isParameterlessConstructor(api)
42+
not api.(CS::Constructor).isParameterless()
4843
}
4944

5045
/**

0 commit comments

Comments
 (0)