33
44namespace StyleCop . Analyzers . Test . ReadabilityRules
55{
6+ using System . Collections . Generic ;
67 using System . Threading ;
78 using System . Threading . Tasks ;
89 using Microsoft . CodeAnalysis . Testing ;
@@ -12,6 +13,26 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules
1213
1314 public class SA1118UnitTests
1415 {
16+ public static IEnumerable < object [ ] > ArrayCreationExpressions { get ; } = new List < object [ ] >
17+ {
18+ new object [ ]
19+ {
20+ @"new[]
21+ {
22+ 0,
23+ 1
24+ }" ,
25+ } ,
26+ new object [ ]
27+ {
28+ @"new int[]
29+ {
30+ 0,
31+ 1
32+ }" ,
33+ } ,
34+ } ;
35+
1536 [ Fact ]
1637 public async Task TestMethodCallWithTwoParametersSecondSpansMoreThanOneLineAsync ( )
1738 {
@@ -276,7 +297,7 @@ public void Bar()
276297 }
277298
278299 [ Fact ]
279- public async Task TestLambdaCallSecondParameterIsAnonynousMethodAsync ( )
300+ public async Task TestLambdaCallSecondParameterIsAnonymousMethodAsync ( )
280301 {
281302 var testCode = @"
282303class Foo
@@ -341,7 +362,7 @@ public void Bar()
341362 }
342363
343364 [ Fact ]
344- public async Task TestAttributeSecondParameterSpandsMultipleLinesAsync ( )
365+ public async Task TestAttributeSecondParameterSpansMultipleLinesAsync ( )
345366 {
346367 var testCode = @"
347368[System.AttributeUsage(System.AttributeTargets.Class,AllowMultiple = true)]
@@ -363,5 +384,27 @@ public class Foo
363384
364385 await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
365386 }
387+
388+ [ Theory ]
389+ [ MemberData ( nameof ( ArrayCreationExpressions ) ) ]
390+ public async Task TestArrayCreationSpansMultipleLinesAsync ( string arrayCreationExpression )
391+ {
392+ var testCode = $@ "
393+ class Foo
394+ {{
395+ public void Fun(int i, int[] j)
396+ {{
397+ }}
398+
399+ public void Bar()
400+ {{
401+ Fun(
402+ 1,
403+ { arrayCreationExpression } );
404+ }}
405+ }}" ;
406+
407+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
408+ }
366409 }
367410}
0 commit comments