Skip to content

Commit e186c9d

Browse files
committed
C#: Update data-flow collection test method names
1 parent 161093b commit e186c9d

File tree

2 files changed

+277
-275
lines changed

2 files changed

+277
-275
lines changed

csharp/ql/test/library-tests/dataflow/collections/CollectionFlow.cs

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Collections.Generic;
44
using System.Linq;
55

6-
public class A
6+
public class CollectionFlow
77
{
8-
public void M1()
8+
public class A { }
9+
10+
public void ArrayInitializerFlow()
911
{
1012
var a = new A();
1113
var @as = new[] { a };
@@ -14,7 +16,7 @@ public void M1()
1416
Sink(First(@as)); // flow
1517
}
1618

17-
public void M2(A other)
19+
public void ArrayInitializerNoFlow(A other)
1820
{
1921
var a = new A();
2022
var @as = new[] { other };
@@ -23,7 +25,7 @@ public void M2(A other)
2325
Sink(First(@as)); // no flow
2426
}
2527

26-
public void M3()
28+
public void ArrayAssignmentFlow()
2729
{
2830
var a = new A();
2931
var @as = new A[1];
@@ -33,7 +35,7 @@ public void M3()
3335
Sink(First(@as)); // flow
3436
}
3537

36-
public void M4(A other)
38+
public void ArrayAssignmentNoFlow(A other)
3739
{
3840
var a = new A();
3941
var @as = new A[1];
@@ -43,7 +45,7 @@ public void M4(A other)
4345
Sink(First(@as)); // no flow
4446
}
4547

46-
public void M5()
48+
public void ListAssignmentFlow()
4749
{
4850
var a = new A();
4951
var list = new List<A>();
@@ -53,7 +55,7 @@ public void M5()
5355
Sink(ListFirst(list)); // flow
5456
}
5557

56-
public void M6(A other)
58+
public void ListAssignmentNoFlow(A other)
5759
{
5860
var list = new List<A>();
5961
list[0] = other;
@@ -62,7 +64,7 @@ public void M6(A other)
6264
Sink(ListFirst(list)); // no flow
6365
}
6466

65-
public void M7()
67+
public void ListInitializerFlow()
6668
{
6769
var a = new A();
6870
var list = new List<A>() { a };
@@ -71,15 +73,15 @@ public void M7()
7173
Sink(ListFirst(list)); // flow
7274
}
7375

74-
public void M8(A other)
76+
public void ListInitializerNoFlow(A other)
7577
{
7678
var list = new List<A>() { other };
7779
Sink(list[0]); // no flow
7880
SinkListElem(list); // no flow
7981
Sink(ListFirst(list)); // no flow
8082
}
8183

82-
public void M9()
84+
public void ListAddFlow()
8385
{
8486
var a = new A();
8587
var list = new List<A>();
@@ -89,7 +91,7 @@ public void M9()
8991
Sink(ListFirst(list)); // flow
9092
}
9193

92-
public void M10(A other)
94+
public void ListAddNoFlow(A other)
9395
{
9496
var list = new List<A>();
9597
list.Add(other);
@@ -98,85 +100,85 @@ public void M10(A other)
98100
Sink(ListFirst(list)); // no flow
99101
}
100102

101-
public void M11()
103+
public void DictionaryAssignmentFlow()
102104
{
103105
var a = new A();
104106
var dict = new Dictionary<int, A>();
105107
dict[0] = a;
106108
Sink(dict[0]); // flow
107109
SinkDictValue(dict); // flow
108-
Sink(DictFirstValueA(dict)); // flow
109-
Sink(DictFirstValueB(dict)); // flow [MISSING]
110-
Sink(DictFirstValueC(dict)); // flow
110+
Sink(DictIndexZero(dict)); // flow
111+
Sink(DictFirstValue(dict)); // flow [MISSING]
112+
Sink(DictValuesFirst(dict)); // flow
111113
}
112114

113-
public void M12(A other)
115+
public void DictionaryAssignmentNoFlow(A other)
114116
{
115117
var dict = new Dictionary<int, A>();
116118
dict[0] = other;
117119
Sink(dict[0]); // no flow
118120
SinkDictValue(dict); // no flow
119-
Sink(DictFirstValueA(dict)); // no flow
120-
Sink(DictFirstValueB(dict)); // no flow
121-
Sink(DictFirstValueC(dict)); // no flow
121+
Sink(DictIndexZero(dict)); // no flow
122+
Sink(DictFirstValue(dict)); // no flow
123+
Sink(DictValuesFirst(dict)); // no flow
122124
}
123125

124-
public void M13()
126+
public void DictionaryValueInitializerFlow()
125127
{
126128
var a = new A();
127129
var dict = new Dictionary<int, A>() { { 0, a } };
128130
Sink(dict[0]); // flow
129131
SinkDictValue(dict); // flow
130-
Sink(DictFirstValueA(dict)); // flow
131-
Sink(DictFirstValueB(dict)); // flow [MISSING]
132-
Sink(DictFirstValueC(dict)); // flow
132+
Sink(DictIndexZero(dict)); // flow
133+
Sink(DictFirstValue(dict)); // flow [MISSING]
134+
Sink(DictValuesFirst(dict)); // flow
133135
}
134136

135-
public void M14(A other)
137+
public void DictionaryValueInitializerNoFlow(A other)
136138
{
137139
var dict = new Dictionary<int, A>() { { 0, other } };
138140
Sink(dict[0]); // no flow
139141
SinkDictValue(dict); // no flow
140-
Sink(DictFirstValueA(dict)); // no flow
141-
Sink(DictFirstValueB(dict)); // no flow
142-
Sink(DictFirstValueC(dict)); // no flow
142+
Sink(DictIndexZero(dict)); // no flow
143+
Sink(DictFirstValue(dict)); // no flow
144+
Sink(DictValuesFirst(dict)); // no flow
143145
}
144146

145-
public void M15()
147+
public void DictionaryKeyInitializerFlow()
146148
{
147149
var a = new A();
148150
var dict = new Dictionary<A, int>() { { a, 0 } };
149151
Sink(dict.Keys.First()); // flow [MISSING]
150152
SinkDictKey(dict); // flow [MISSING]
151-
Sink(DictFirstKeyA(dict)); // flow [MISSING]
152-
Sink(DictFirstKeyB(dict)); // flow [MISSING]
153+
Sink(DictKeysFirst(dict)); // flow [MISSING]
154+
Sink(DictFirstKey(dict)); // flow [MISSING]
153155
}
154156

155-
public void M16(A other)
157+
public void DictionaryKeyInitializerNoFlow(A other)
156158
{
157159
var dict = new Dictionary<A, int>() { { other, 0 } };
158160
Sink(dict.Keys.First()); // no flow
159161
SinkDictKey(dict); // no flow
160-
Sink(DictFirstKeyA(dict)); // no flow
161-
Sink(DictFirstKeyB(dict)); // no flow
162+
Sink(DictKeysFirst(dict)); // no flow
163+
Sink(DictFirstKey(dict)); // no flow
162164
}
163165

164-
public void M17()
166+
public void ForeachFlow()
165167
{
166168
var a = new A();
167169
var @as = new[] { a };
168170
foreach (var x in @as)
169171
Sink(x); // flow
170172
}
171173

172-
public void M18(A other)
174+
public void ForeachNoFlow(A other)
173175
{
174176
var @as = new[] { other };
175177
foreach (var x in @as)
176178
Sink(x); // no flow
177179
}
178180

179-
public void M19()
181+
public void ArrayGetEnumeratorFlow()
180182
{
181183
var a = new A();
182184
var @as = new[] { a };
@@ -185,15 +187,15 @@ public void M19()
185187
Sink(enumerator.Current); // flow
186188
}
187189

188-
public void M20(A other)
190+
public void ArrayGetEnumeratorNoFlow(A other)
189191
{
190192
var @as = new[] { other };
191193
var enumerator = @as.GetEnumerator();
192194
while (enumerator.MoveNext())
193195
Sink(enumerator.Current); // no flow
194196
}
195197

196-
public void M21()
198+
public void ListGetEnumeratorFlow()
197199
{
198200
var a = new A();
199201
var list = new List<A>();
@@ -217,13 +219,13 @@ public static void Sink<T>(T t) { }
217219

218220
public static T ListFirst<T>(IList<T> list) => list[0];
219221

220-
public static T DictFirstValueA<T>(IDictionary<int, T> dict) => dict[0];
222+
public static T DictIndexZero<T>(IDictionary<int, T> dict) => dict[0];
221223

222-
public static T DictFirstValueB<T>(IDictionary<int, T> dict) => dict.First().Value;
224+
public static T DictFirstValue<T>(IDictionary<int, T> dict) => dict.First().Value;
223225

224-
public static T DictFirstValueC<T>(IDictionary<int, T> dict) => dict.Values.First();
226+
public static T DictValuesFirst<T>(IDictionary<int, T> dict) => dict.Values.First();
225227

226-
public static T DictFirstKeyA<T>(IDictionary<T, int> dict) => dict.Keys.First();
228+
public static T DictKeysFirst<T>(IDictionary<T, int> dict) => dict.Keys.First();
227229

228-
public static T DictFirstKeyB<T>(IDictionary<T, int> dict) => dict.First().Key;
230+
public static T DictFirstKey<T>(IDictionary<T, int> dict) => dict.First().Key;
229231
}

0 commit comments

Comments
 (0)