-
Notifications
You must be signed in to change notification settings - Fork 2k
C#: Add model validation for constructor summary models #21416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,12 +239,23 @@ module ModelValidation { | |
| ) | ||
| } | ||
|
|
||
| string getIncorrectConstructorSummaryOutput() { | ||
| exists(string namespace, string type, string name, string output | | ||
| summaryModel(namespace, type, _, name, _, _, _, output, _, _, _) and | ||
| type = name and | ||
| output.matches("ReturnValue%") and | ||
| result = | ||
| "Constructor model for " + namespace + "." + type + | ||
| " should use `Argument[this]` in the output, not `ReturnValue`." | ||
| ) | ||
| } | ||
|
|
||
| /** Holds if some row in a MaD flow model appears to contain typos. */ | ||
| query predicate invalidModelRow(string msg) { | ||
| msg = | ||
| [ | ||
| getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(), | ||
| KindVal::getInvalidModelKind() | ||
| getIncorrectConstructorSummaryOutput(), KindVal::getInvalidModelKind() | ||
|
Comment on lines
255
to
+260
|
||
| ] | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for generics. As opposed to Java, C# doesn't used "erased" types in MaD. This means that a type could be
C<T1,T2>, but the constructor name is onlyC. For types you need to remove everything after (and including) the first<intypebefore comparing toname.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I've added a commit to address this (in a different way than you suggested, which shows that I didn't even read your whole comment 😬 ). Again, I tested it by modifying an existing model (a constructor of a generic type this time) to have the problem and checking that it was found by the test.