Skip to content

Commit a3e9aed

Browse files
authored
Merge pull request #21416 from owen-mc/csharp/validate-constructor-summary-models
C#: Add model validation for constructor summary models
2 parents e96ba48 + 3c36a9e commit a3e9aed

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,25 @@ module ModelValidation {
239239
)
240240
}
241241

242+
string getIncorrectConstructorSummaryOutput() {
243+
exists(string namespace, string type, string name, string output |
244+
type = name or
245+
type = name + "<" + any(string s)
246+
|
247+
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _) and
248+
output.matches("ReturnValue%") and
249+
result =
250+
"Constructor model for " + namespace + "." + type +
251+
" should use `Argument[this]` in the output, not `ReturnValue`."
252+
)
253+
}
254+
242255
/** Holds if some row in a MaD flow model appears to contain typos. */
243256
query predicate invalidModelRow(string msg) {
244257
msg =
245258
[
246259
getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(),
247-
KindVal::getInvalidModelKind()
260+
getIncorrectConstructorSummaryOutput(), KindVal::getInvalidModelKind()
248261
]
249262
}
250263
}

0 commit comments

Comments
 (0)