@@ -85,11 +85,11 @@ public void TestMethod()
8585 }
8686
8787 /// <summary>
88- /// Verifies that diagnostics will be reported for all invalid array initializer definitions.
88+ /// Verifies that diagnostics will be reported for all invalid implicit array initializer definitions.
8989 /// </summary>
9090 /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
9191 [ Fact ]
92- public async Task TestArrayInitializersInvalidAsync ( )
92+ public async Task TestImplicitArrayInitializersInvalidAsync ( )
9393 {
9494 var testCode = @"
9595public class TestClass
@@ -251,5 +251,96 @@ public void TestMethod()
251251 await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
252252 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
253253 }
254+
255+ /// <summary>
256+ /// Verifies that diagnostics will be reported for all invalid array initializer definitions.
257+ /// </summary>
258+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
259+ [ Fact ]
260+ [ WorkItem ( 2607 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2607" ) ]
261+ public async Task TestArrayInitializersInvalidAsync ( )
262+ {
263+ var testCode = @"
264+ public class TestClass
265+ {
266+ private int[] invalidArray5 = new int[]
267+ { 0, 1 };
268+
269+ private int[] invalidArray6 = new int[]
270+ { 0, 1
271+ };
272+
273+ private int[] invalidArray7 = new int[]
274+ {
275+ 0, 1 };
276+
277+ public void TestMethod()
278+ {
279+ var invalidArray12 = new int[]
280+ { 0, 1 };
281+
282+ var invalidArray13 = new int[]
283+ { 0, 1
284+ };
285+
286+ var invalidArray14 = new int[]
287+ {
288+ 0, 1 };
289+ }
290+ }" ;
291+
292+ var fixedTestCode = @"
293+ public class TestClass
294+ {
295+ private int[] invalidArray5 = new int[]
296+ {
297+ 0, 1
298+ };
299+
300+ private int[] invalidArray6 = new int[]
301+ {
302+ 0, 1
303+ };
304+
305+ private int[] invalidArray7 = new int[]
306+ {
307+ 0, 1
308+ };
309+
310+ public void TestMethod()
311+ {
312+ var invalidArray12 = new int[]
313+ {
314+ 0, 1
315+ };
316+
317+ var invalidArray13 = new int[]
318+ {
319+ 0, 1
320+ };
321+
322+ var invalidArray14 = new int[]
323+ {
324+ 0, 1
325+ };
326+ }
327+ }" ;
328+
329+ DiagnosticResult [ ] expectedDiagnostics =
330+ {
331+ this . CSharpDiagnostic ( ) . WithLocation ( 5 , 9 ) ,
332+ this . CSharpDiagnostic ( ) . WithLocation ( 5 , 16 ) ,
333+ this . CSharpDiagnostic ( ) . WithLocation ( 8 , 9 ) ,
334+ this . CSharpDiagnostic ( ) . WithLocation ( 13 , 18 ) ,
335+ this . CSharpDiagnostic ( ) . WithLocation ( 18 , 13 ) ,
336+ this . CSharpDiagnostic ( ) . WithLocation ( 18 , 20 ) ,
337+ this . CSharpDiagnostic ( ) . WithLocation ( 21 , 13 ) ,
338+ this . CSharpDiagnostic ( ) . WithLocation ( 26 , 22 ) ,
339+ } ;
340+
341+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostics , CancellationToken . None ) . ConfigureAwait ( false ) ;
342+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
343+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
344+ }
254345 }
255346}
0 commit comments