Skip to content

Commit a3691c9

Browse files
committed
simplify collection intialization
1 parent c9750d4 commit a3691c9

16 files changed

+75
-73
lines changed

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AsyncAwait.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void AsyncAwait()
3737

3838
}, persistPrepareResultToFile: pathSerialize[0]);
3939
return 0;
40-
}, new string[] { path });
40+
}, [path]);
4141

4242
TestInstrumentationHelper.GetCoverageResult(path)
4343
.Document("Instrumentation.AsyncAwait.cs")
@@ -87,7 +87,7 @@ public void AsyncAwait_Issue_669_1()
8787
persistPrepareResultToFile: pathSerialize[0]);
8888

8989
return 0;
90-
}, new string[] { path });
90+
}, [path]);
9191

9292
TestInstrumentationHelper.GetCoverageResult(path)
9393
.Document("Instrumentation.AsyncAwait.cs")
@@ -118,7 +118,7 @@ public void AsyncAwait_Issue_669_2()
118118
assemblyLocation: Assembly.GetExecutingAssembly().Location);
119119

120120
return 0;
121-
}, new string[] { path });
121+
}, [path]);
122122

123123
TestInstrumentationHelper.GetCoverageResult(path)
124124
.Document("Instrumentation.AsyncAwait.cs")
@@ -146,7 +146,7 @@ public void AsyncAwait_Issue_1177()
146146
persistPrepareResultToFile: pathSerialize[0]);
147147

148148
return 0;
149-
}, new string[] { path });
149+
}, [path]);
150150

151151
Core.Instrumentation.Document document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs");
152152
document.AssertLinesCovered(BuildConfiguration.Debug, (133, 1), (134, 1), (135, 1), (136, 1), (137, 1));
@@ -173,7 +173,7 @@ public void AsyncAwait_Issue_1233()
173173
persistPrepareResultToFile: pathSerialize[0]);
174174

175175
return 0;
176-
}, new string[] { path });
176+
}, [path]);
177177

178178
Core.Instrumentation.Document document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs");
179179
document.AssertLinesCovered(BuildConfiguration.Debug, (150, 1));
@@ -201,7 +201,7 @@ public void AsyncAwait_Issue_1275()
201201
persistPrepareResultToFile: pathSerialize[0]);
202202

203203
return 0;
204-
}, new string[] { path });
204+
}, [path]);
205205

206206
Core.Instrumentation.Document document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs");
207207
document.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 170, 176);

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AsyncAwaitValueTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void AsyncAwaitWithValueTask()
3333
res = await (Task<int>)instance.WrappingValueTaskAsTask();
3434
}, persistPrepareResultToFile: pathSerialize[0]);
3535
return 0;
36-
}, new string[] { path });
36+
}, [path]);
3737

3838
TestInstrumentationHelper.GetCoverageResult(path)
3939
.Document("Instrumentation.AsyncAwaitValueTask.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AsyncForeach.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void AsyncForeach()
3131

3232
}, persistPrepareResultToFile: pathSerialize[0]);
3333
return 0;
34-
}, new string[] { path });
34+
}, [path]);
3535

3636
TestInstrumentationHelper.GetCoverageResult(path)
3737
.Document("Instrumentation.AsyncForeach.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AsyncIterator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void AsyncIterator()
2828

2929
}, persistPrepareResultToFile: pathSerialize[0]);
3030
return 0;
31-
}, new string[] { path });
31+
}, [path]);
3232

3333
TestInstrumentationHelper.GetCoverageResult(path)
3434
.Document("Instrumentation.AsyncIterator.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AutoProps.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void SkipAutoProps(bool skipAutoProps)
3434
persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1]));
3535

3636
return 0;
37-
}, new string[] { path, skipAutoProps.ToString() });
37+
}, [path, skipAutoProps.ToString()]);
3838

3939
if (skipAutoProps)
4040
{
@@ -82,7 +82,7 @@ public void SkipAutoPropsInRecords(bool skipAutoProps)
8282
persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1]));
8383

8484
return 0;
85-
}, new string[] { path, skipAutoProps.ToString() });
85+
}, [path, skipAutoProps.ToString()]);
8686

8787
if (skipAutoProps)
8888
{
@@ -125,7 +125,7 @@ public void SkipRecordWithProperties(bool skipAutoProps)
125125
persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1]));
126126

127127
return 0;
128-
}, new string[] { path, skipAutoProps.ToString() });
128+
}, [path, skipAutoProps.ToString()]);
129129

130130
if (skipAutoProps)
131131
{
@@ -167,7 +167,7 @@ public void SkipInheritingRecordsWithProperties(bool skipAutoProps)
167167
persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1]));
168168

169169
return 0;
170-
}, new string[] { path, skipAutoProps.ToString() });
170+
}, [path, skipAutoProps.ToString()]);
171171

172172
if (skipAutoProps)
173173
{

test/coverlet.core.coverage.tests/Coverage/CoverageTests.AwaitUsing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void AwaitUsing()
2929

3030
}, persistPrepareResultToFile: pathSerialize[0]);
3131
return 0;
32-
}, new string[] { path });
32+
}, [path]);
3333

3434
TestInstrumentationHelper.GetCoverageResult(path)
3535
.Document("Instrumentation.AwaitUsing.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.CatchBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void CatchBlock_Issue465()
6666

6767
}, persistPrepareResultToFile: pathSerialize[0]);
6868
return 0;
69-
}, new string[] { path });
69+
}, [path]);
7070

7171
CoverageResult res = TestInstrumentationHelper.GetCoverageResult(path);
7272
res.Document("Instrumentation.CatchBlock.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.DoesNotReturn.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public void NoBranches_DoesNotReturnAttribute_InstrumentsCorrect()
2929
catch (Exception) { }
3030
return Task.CompletedTask;
3131

32-
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });
32+
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => ["DoesNotReturnAttribute"]);
3333

3434
return 0;
3535

36-
}, new string[] { path });
36+
}, [path]);
3737

3838
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
3939

@@ -65,7 +65,7 @@ public void If_DoesNotReturnAttribute_InstrumentsCorrect()
6565

6666
return 0;
6767

68-
}, new string[] { path });
68+
}, [path]);
6969

7070
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
7171

@@ -96,7 +96,7 @@ public void Switch_DoesNotReturnAttribute_InstrumentsCorrect()
9696

9797
return 0;
9898

99-
}, new string[] { path });
99+
}, [path]);
100100

101101
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
102102

@@ -127,7 +127,7 @@ public void Subtle_DoesNotReturnAttribute_InstrumentsCorrect()
127127

128128
return 0;
129129

130-
}, new string[] { path });
130+
}, [path]);
131131

132132
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
133133

@@ -158,7 +158,7 @@ public void UnreachableBranch_DoesNotReturnAttribute_InstrumentsCorrect()
158158

159159
return 0;
160160

161-
}, new string[] { path });
161+
}, [path]);
162162

163163
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
164164

@@ -185,11 +185,11 @@ public void CallsGenericMethodDoesNotReturn_DoesNotReturnAttribute_InstrumentsCo
185185
catch (Exception) { }
186186
return Task.CompletedTask;
187187

188-
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });
188+
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => ["DoesNotReturnAttribute"]);
189189

190190
return 0;
191191

192-
}, new string[] { path });
192+
}, [path]);
193193

194194
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
195195

@@ -217,11 +217,11 @@ public void CallsGenericClassDoesNotReturn_DoesNotReturnAttribute_InstrumentsCor
217217
catch (Exception) { }
218218
return Task.CompletedTask;
219219

220-
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });
220+
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => ["DoesNotReturnAttribute"]);
221221

222222
return 0;
223223

224-
}, new string[] { path });
224+
}, [path]);
225225

226226
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
227227

@@ -249,11 +249,11 @@ public void WithLeave_DoesNotReturnAttribute_InstrumentsCorrect()
249249
catch (Exception) { }
250250
return Task.CompletedTask;
251251

252-
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });
252+
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => ["DoesNotReturnAttribute"]);
253253

254254
return 0;
255255

256-
}, new string[] { path });
256+
}, [path]);
257257

258258
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
259259

@@ -281,11 +281,11 @@ public void FiltersAndFinally_DoesNotReturnAttribute_InstrumentsCorrect()
281281
catch (Exception) { }
282282
return Task.CompletedTask;
283283

284-
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" });
284+
}, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => ["DoesNotReturnAttribute"]);
285285

286286
return 0;
287287

288-
}, new string[] { path });
288+
}, [path]);
289289

290290
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
291291

test/coverlet.core.coverage.tests/Coverage/CoverageTests.ExcludeFromCoverageAttribute.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void ExcludeFromCodeCoverage_CompilerGeneratedMethodsAndTypes()
2929

3030
return 0;
3131

32-
}, new string[] { path });
32+
}, [path]);
3333

3434
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
3535

@@ -70,7 +70,7 @@ public void ExcludeFromCodeCoverage_CompilerGeneratedMethodsAndTypes_NestedMembe
7070

7171
return 0;
7272

73-
}, new string[] { path });
73+
}, [path]);
7474

7575
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path)
7676
.GenerateReport(show: true);
@@ -101,7 +101,7 @@ public void ExcludeFromCodeCoverageCompilerGeneratedMethodsAndTypes_Issue670()
101101

102102
return 0;
103103

104-
}, new string[] { path });
104+
}, [path]);
105105

106106
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);
107107

@@ -130,7 +130,7 @@ public void ExcludeFromCodeCoverageNextedTypes()
130130
}, persistPrepareResultToFile: pathSerialize[0]);
131131

132132
return 0;
133-
}, new string[] { path });
133+
}, [path]);
134134

135135
TestInstrumentationHelper.GetCoverageResult(path)
136136
.GenerateReport(show: true)
@@ -158,7 +158,7 @@ public void ExcludeFromCodeCoverage_Issue809()
158158
}, persistPrepareResultToFile: pathSerialize[0]);
159159

160160
return 0;
161-
}, new string[] { path });
161+
}, [path]);
162162

163163
TestInstrumentationHelper.GetCoverageResult(path)
164164
.Document("Instrumentation.ExcludeFromCoverage.Issue809.cs")
@@ -195,7 +195,7 @@ public void ExcludeFromCodeCoverageAutoGeneratedGetSet()
195195
}, persistPrepareResultToFile: pathSerialize[0]);
196196

197197
return 0;
198-
}, new string[] { path });
198+
}, [path]);
199199

200200
TestInstrumentationHelper.GetCoverageResult(path)
201201
.Document("Instrumentation.ExcludeFromCoverage.cs")
@@ -224,7 +224,7 @@ public void ExcludeFromCodeCoverageAutoGeneratedGet()
224224
}, persistPrepareResultToFile: pathSerialize[0]);
225225

226226
return 0;
227-
}, new string[] { path });
227+
}, [path]);
228228

229229
TestInstrumentationHelper.GetCoverageResult(path)
230230
.Document("Instrumentation.ExcludeFromCoverage.cs")
@@ -252,7 +252,7 @@ public void ExcludeFromCodeCoverage_Issue1302()
252252
}, persistPrepareResultToFile: pathSerialize[0]);
253253

254254
return 0;
255-
}, new string[] { path });
255+
}, [path]);
256256

257257
TestInstrumentationHelper.GetCoverageResult(path)
258258
.Document("Instrumentation.ExcludeFromCoverage.Issue1302.cs")
@@ -287,7 +287,7 @@ await TestInstrumentationHelper.Run<MethodsWithExcludeFromCodeCoverageAttr>(asyn
287287
persistPrepareResultToFile: pathSerialize[0]);
288288

289289
return 0;
290-
}, new string[] { path });
290+
}, [path]);
291291

292292
TestInstrumentationHelper.GetCoverageResult(path)
293293
.GenerateReport(show: true)
@@ -324,7 +324,7 @@ await TestInstrumentationHelper.Run<MethodsWithExcludeFromCodeCoverageAttr2>(asy
324324
persistPrepareResultToFile: pathSerialize[0]);
325325

326326
return 0;
327-
}, new string[] { path });
327+
}, [path]);
328328

329329
TestInstrumentationHelper.GetCoverageResult(path)
330330
.GenerateReport(show: true)

test/coverlet.core.coverage.tests/Coverage/CoverageTests.Filters.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public void ExcludeFilteredNestedAutogeneratedTypes()
5050

5151
return Task.CompletedTask;
5252
},
53-
includeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterNestedAutogeneratedTypes", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Issue_689" },
54-
excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*NestedToFilterOut", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Uncoverlet" },
53+
includeFilter: moduleFileName => [$"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterNestedAutogeneratedTypes", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Issue_689"],
54+
excludeFilter: moduleFileName => [$"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*NestedToFilterOut", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Uncoverlet"],
5555
persistPrepareResultToFile: pathSerialize[0]);
5656

5757
return 0;
58-
}, new string[] { path });
58+
}, [path]);
5959

6060
TestInstrumentationHelper.GetCoverageResult(path)
6161
.Document("Instrumentation.ExcludeFilter.cs")
@@ -85,11 +85,11 @@ public void ExcludeFilteredTypes()
8585
Assert.Equal(42, instance.Run());
8686
return Task.CompletedTask;
8787
},
88-
excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterOuterTypes" },
88+
excludeFilter: moduleFileName => [$"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterOuterTypes"],
8989
persistPrepareResultToFile: pathSerialize[0]);
9090

9191
return 0;
92-
}, new string[] { path });
92+
}, [path]);
9393

9494
TestInstrumentationHelper.GetCoverageResult(path)
9595
.Document("Instrumentation.ExcludeFilter.cs")
@@ -115,11 +115,11 @@ public void ExcludeFilteredNestedTypes()
115115
Assert.Equal(42, instance.Run());
116116
return Task.CompletedTask;
117117
},
118-
excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterClass2" },
118+
excludeFilter: moduleFileName => [$"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterClass2"],
119119
persistPrepareResultToFile: pathSerialize[0]);
120120

121121
return 0;
122-
}, new string[] { path });
122+
}, [path]);
123123

124124
TestInstrumentationHelper.GetCoverageResult(path)
125125
.Document("Instrumentation.ExcludeFilter.cs")

test/coverlet.core.coverage.tests/Coverage/CoverageTests.GenericAsyncIterator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void GenericAsyncIterator()
2727
List<int> res = await (Task<List<int>>)instance.Issue1383();
2828
}, persistPrepareResultToFile: pathSerialize[0]);
2929
return 0;
30-
}, new string[] { path });
30+
}, [path]);
3131

3232
TestInstrumentationHelper.GetCoverageResult(path)
3333
.Document("Instrumentation.GenericAsyncIterator.cs")

0 commit comments

Comments
 (0)