C#: Update tests to exclude autogenerated parameterizables in attributes as these appears to give OS dependent results.

This commit is contained in:
Michael Nebel
2023-05-17 15:11:26 +02:00
parent 5a57d47b6c
commit 6cb2ce5a38
2 changed files with 11 additions and 7 deletions

View File

@@ -11,10 +11,6 @@ noDefaultValue
| Parameters.dll:0:0:0:0 | M2 | Parameters.dll:0:0:0:0 | a | 0 |
| Parameters.dll:0:0:0:0 | M6 | Parameters.dll:0:0:0:0 | s1 | 0 |
| Parameters.dll:0:0:0:0 | M7 | Parameters.dll:0:0:0:0 | e1 | 0 |
| Parameters.dll:0:0:0:0 | NullableAttribute | Parameters.dll:0:0:0:0 | value | 0 |
| Parameters.dll:0:0:0:0 | NullableAttribute | Parameters.dll:0:0:0:0 | value | 0 |
| Parameters.dll:0:0:0:0 | NullableContextAttribute | Parameters.dll:0:0:0:0 | value | 0 |
| Parameters.dll:0:0:0:0 | RefSafetyRulesAttribute | Parameters.dll:0:0:0:0 | value | 0 |
withDefaultValue
| Parameters.cs:8:17:8:18 | M2 | Parameters.cs:8:34:8:34 | b | 1 | Parameters.cs:8:38:8:41 | null | null |
| Parameters.cs:8:17:8:18 | M2 | Parameters.cs:8:51:8:51 | c | 2 | Parameters.cs:8:55:8:70 | "default string" | default string |

View File

@@ -4,10 +4,16 @@ private predicate fromTestLocation(Element e) {
e.fromSource() or e.getFile().getStem() = "Parameters"
}
private predicate compilerGeneratedAttribute(Parameterizable container) {
container.getDeclaringType().getAnAttribute().getType().toStringWithTypes() =
"CompilerGeneratedAttribute"
}
query predicate noDefaultValue(Parameterizable container, Parameter p, int i) {
fromTestLocation(container) and
not p.hasDefaultValue() and
container.getParameter(i) = p
container.getParameter(i) = p and
not compilerGeneratedAttribute(container)
}
query predicate withDefaultValue(Parameterizable container, Parameter p, int i, Expr e, string value) {
@@ -15,7 +21,8 @@ query predicate withDefaultValue(Parameterizable container, Parameter p, int i,
p.hasDefaultValue() and
container.getParameter(i) = p and
p.getDefaultValue() = e and
if exists(e.getValue()) then value = e.getValue() else value = "-"
(if exists(e.getValue()) then value = e.getValue() else value = "-") and
not compilerGeneratedAttribute(container)
}
query predicate dateTimeDefaults(
@@ -26,5 +33,6 @@ query predicate dateTimeDefaults(
container.getAParameter() = p and
p.getDefaultValue() = o and
o.getTarget().toStringWithTypes() = constructor and
o.getAnArgument().getValue() = value
o.getAnArgument().getValue() = value and
not compilerGeneratedAttribute(container)
}