Skip to content

Commit d09fadf

Browse files
committed
C#: Introduce TestRelatedFile class
1 parent 0f71df9 commit d09fadf

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

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

1212
override predicate isSource() { this instanceof SourceCallable }
1313

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

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

112112
string methodClassification(Call method) {
113-
method.getFile() instanceof TestFile and result = "test"
113+
method.getFile() instanceof TestRelatedFile and result = "test"
114114
or
115-
not method.getFile() instanceof TestFile and
115+
not method.getFile() instanceof TestRelatedFile and
116116
result = "source"
117117
}
118118

@@ -130,9 +130,11 @@ private string qualifiedCallableName(string namespace, string type, Callable c)
130130
exists(string name | hasQualifiedMethodName(c, namespace, type, name) | result = name)
131131
}
132132

133-
/** A file that doesn't contain tests itself, but is only used in tests. */
134-
class TestSupportFile extends TestFile {
135-
TestSupportFile() {
133+
/** A file that is either a test file or is only used in tests. */
134+
class TestRelatedFile extends File {
135+
TestRelatedFile() {
136+
this instanceof TestFile
137+
or
136138
this.getAbsolutePath().matches(["%/test/%", "%/tests/%"]) and
137139
not this.getAbsolutePath().matches("%/ql/test/%") // allows our test cases to work
138140
}

0 commit comments

Comments
 (0)