Skip to content

Commit 6cb2ce5

Browse files
committed
C#: Update tests to exclude autogenerated parameterizables in attributes as these appears to give OS dependent results.
1 parent 5a57d47 commit 6cb2ce5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

csharp/ql/test/library-tests/parameters/Parameters.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ noDefaultValue
1111
| Parameters.dll:0:0:0:0 | M2 | Parameters.dll:0:0:0:0 | a | 0 |
1212
| Parameters.dll:0:0:0:0 | M6 | Parameters.dll:0:0:0:0 | s1 | 0 |
1313
| Parameters.dll:0:0:0:0 | M7 | Parameters.dll:0:0:0:0 | e1 | 0 |
14-
| Parameters.dll:0:0:0:0 | NullableAttribute | Parameters.dll:0:0:0:0 | value | 0 |
15-
| Parameters.dll:0:0:0:0 | NullableAttribute | Parameters.dll:0:0:0:0 | value | 0 |
16-
| Parameters.dll:0:0:0:0 | NullableContextAttribute | Parameters.dll:0:0:0:0 | value | 0 |
17-
| Parameters.dll:0:0:0:0 | RefSafetyRulesAttribute | Parameters.dll:0:0:0:0 | value | 0 |
1814
withDefaultValue
1915
| Parameters.cs:8:17:8:18 | M2 | Parameters.cs:8:34:8:34 | b | 1 | Parameters.cs:8:38:8:41 | null | null |
2016
| 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 |

csharp/ql/test/library-tests/parameters/Parameters.ql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ private predicate fromTestLocation(Element e) {
44
e.fromSource() or e.getFile().getStem() = "Parameters"
55
}
66

7+
private predicate compilerGeneratedAttribute(Parameterizable container) {
8+
container.getDeclaringType().getAnAttribute().getType().toStringWithTypes() =
9+
"CompilerGeneratedAttribute"
10+
}
11+
712
query predicate noDefaultValue(Parameterizable container, Parameter p, int i) {
813
fromTestLocation(container) and
914
not p.hasDefaultValue() and
10-
container.getParameter(i) = p
15+
container.getParameter(i) = p and
16+
not compilerGeneratedAttribute(container)
1117
}
1218

1319
query predicate withDefaultValue(Parameterizable container, Parameter p, int i, Expr e, string value) {
1420
fromTestLocation(container) and
1521
p.hasDefaultValue() and
1622
container.getParameter(i) = p and
1723
p.getDefaultValue() = e and
18-
if exists(e.getValue()) then value = e.getValue() else value = "-"
24+
(if exists(e.getValue()) then value = e.getValue() else value = "-") and
25+
not compilerGeneratedAttribute(container)
1926
}
2027

2128
query predicate dateTimeDefaults(
@@ -26,5 +33,6 @@ query predicate dateTimeDefaults(
2633
container.getAParameter() = p and
2734
p.getDefaultValue() = o and
2835
o.getTarget().toStringWithTypes() = constructor and
29-
o.getAnArgument().getValue() = value
36+
o.getAnArgument().getValue() = value and
37+
not compilerGeneratedAttribute(container)
3038
}

0 commit comments

Comments
 (0)