Skip to content

Commit 0f71df9

Browse files
committed
C#: Extend TestFile instead of separate class
1 parent d22acfb commit 0f71df9

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

csharp/ql/src/utils/modeleditor/FrameworkModeEndpointsQuery.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ private import ModelEditor
77
* A class of effectively public callables from source code.
88
*/
99
class PublicEndpointFromSource extends Endpoint {
10-
PublicEndpointFromSource() {
11-
this.fromSource() and
12-
not this.getFile() instanceof TestFile and
13-
not this.getFile() instanceof TestSupportFile
14-
}
10+
PublicEndpointFromSource() { this.fromSource() and not this.getFile() instanceof TestFile }
1511

1612
override predicate isSource() { this instanceof SourceCallable }
1713

csharp/ql/src/utils/modeleditor/ModelEditor.qll

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ string supportedType(Endpoint endpoint) {
110110
}
111111

112112
string methodClassification(Call method) {
113-
(method.getFile() instanceof TestFile or method.getFile() instanceof TestSupportFile) and
114-
result = "test"
113+
method.getFile() instanceof TestFile and result = "test"
115114
or
116115
not method.getFile() instanceof TestFile and
117-
not method.getFile() instanceof TestSupportFile and
118116
result = "source"
119117
}
120118

@@ -133,9 +131,8 @@ private string qualifiedCallableName(string namespace, string type, Callable c)
133131
}
134132

135133
/** A file that doesn't contain tests itself, but is only used in tests. */
136-
class TestSupportFile extends File {
134+
class TestSupportFile extends TestFile {
137135
TestSupportFile() {
138-
not this instanceof TestFile and
139136
this.getAbsolutePath().matches(["%/test/%", "%/tests/%"]) and
140137
not this.getAbsolutePath().matches("%/ql/test/%") // allows our test cases to work
141138
}

0 commit comments

Comments
 (0)