11// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
4- #nullable disable
5-
64namespace StyleCop . Analyzers . Test . SpacingRules
75{
86 using System . Threading ;
@@ -54,15 +52,17 @@ public async Task TestStringInterpolationAsync()
5452{
5553 public class TestClass
5654 {
57- public void TestMethod()
55+ public void TestMethod(int a, int b )
5856 {
5957 var test = 2;
6058 var x = $""{test}"";
6159 x = $""{test}"";
6260 x = $""({test})"";
6361 x = $""({test} )"";
64- x = $""{test }"";
65- x = $""{test } "";
62+ x = $""{test {|#0:}|}"";
63+ x = $""{test {|#1:}|} "";
64+ x = $""{new { a, b{|#2:}|}}"";
65+ x = $""{new { a, b } {|#3:}|}"";
6666 }
6767 }
6868}
@@ -72,7 +72,7 @@ public void TestMethod()
7272{
7373 public class TestClass
7474 {
75- public void TestMethod()
75+ public void TestMethod(int a, int b )
7676 {
7777 var test = 2;
7878 var x = $""{test}"";
@@ -81,15 +81,19 @@ public void TestMethod()
8181 x = $""({test} )"";
8282 x = $""{test}"";
8383 x = $""{test} "";
84+ x = $""{new { a, b }}"";
85+ x = $""{new { a, b }}"";
8486 }
8587 }
8688}
8789" ;
8890
8991 DiagnosticResult [ ] expected =
9092 {
91- Diagnostic ( ) . WithLocation ( 12 , 25 ) . WithArguments ( " not" , "preceded" ) ,
92- Diagnostic ( ) . WithLocation ( 13 , 25 ) . WithArguments ( " not" , "preceded" ) ,
93+ Diagnostic ( ) . WithLocation ( 0 ) . WithArguments ( " not" , "preceded" ) ,
94+ Diagnostic ( ) . WithLocation ( 1 ) . WithArguments ( " not" , "preceded" ) ,
95+ Diagnostic ( ) . WithLocation ( 2 ) . WithArguments ( string . Empty , "preceded" ) ,
96+ Diagnostic ( ) . WithLocation ( 3 ) . WithArguments ( " not" , "preceded" ) ,
9397 } ;
9498
9599 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -107,7 +111,7 @@ public async Task TestPropertyDeclarationAsync()
107111 public class TestClass
108112 {
109113 public int TestProperty1 { get; set; }
110- public int TestProperty2 { get; set;}
114+ public int TestProperty2 { get; set;{|#0:}| }
111115 }
112116}
113117" ;
@@ -124,7 +128,7 @@ public class TestClass
124128
125129 DiagnosticResult [ ] expected =
126130 {
127- Diagnostic ( ) . WithLocation ( 6 , 45 ) . WithArguments ( string . Empty , "preceded" ) ,
131+ Diagnostic ( ) . WithLocation ( 0 ) . WithArguments ( string . Empty , "preceded" ) ,
128132 } ;
129133
130134 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -146,9 +150,9 @@ public class TestClass
146150 public void TestMethod()
147151 {
148152 new Dictionary<int, int> { { 1, 1 } };
149- new Dictionary<int, int> { { 1, 1} };
150- new Dictionary<int, int> { { 1, 1 } };
151- new Dictionary<int, int> { { 1, 1} };
153+ new Dictionary<int, int> { { 1, 1{|#0:}| } };
154+ new Dictionary<int, int> { { 1, 1 {|#1:}|}{|#2:}| };
155+ new Dictionary<int, int> { { 1, 1{|#3:}|}{|#4:}| };
152156 }
153157 }
154158}
@@ -173,12 +177,12 @@ public void TestMethod()
173177
174178 DiagnosticResult [ ] expected =
175179 {
176- Diagnostic ( ) . WithLocation ( 10 , 46 ) . WithArguments ( string . Empty , "preceded" ) ,
177- Diagnostic ( ) . WithLocation ( 11 , 47 ) . WithArguments ( string . Empty , "followed" ) ,
178- Diagnostic ( ) . WithLocation ( 11 , 48 ) . WithArguments ( string . Empty , "preceded" ) ,
179- Diagnostic ( ) . WithLocation ( 12 , 46 ) . WithArguments ( string . Empty , "preceded" ) ,
180- Diagnostic ( ) . WithLocation ( 12 , 46 ) . WithArguments ( string . Empty , "followed" ) ,
181- Diagnostic ( ) . WithLocation ( 12 , 47 ) . WithArguments ( string . Empty , "preceded" ) ,
180+ Diagnostic ( ) . WithLocation ( 0 ) . WithArguments ( string . Empty , "preceded" ) ,
181+ Diagnostic ( ) . WithLocation ( 1 ) . WithArguments ( string . Empty , "followed" ) ,
182+ Diagnostic ( ) . WithLocation ( 2 ) . WithArguments ( string . Empty , "preceded" ) ,
183+ Diagnostic ( ) . WithLocation ( 3 ) . WithArguments ( string . Empty , "preceded" ) ,
184+ Diagnostic ( ) . WithLocation ( 3 ) . WithArguments ( string . Empty , "followed" ) ,
185+ Diagnostic ( ) . WithLocation ( 4 ) . WithArguments ( string . Empty , "preceded" ) ,
182186 } ;
183187
184188 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -297,9 +301,9 @@ public void TestMethod1(object[] a)
297301 public void TestMethod2()
298302 {
299303 TestMethod1(new object[] { });
300- TestMethod1(new object[] {});
304+ TestMethod1(new object[] {{|#0:}| });
301305 TestMethod1(new object[] { } );
302- TestMethod1(new object[] {} );
306+ TestMethod1(new object[] {{|#1:}| } );
303307 }
304308 }
305309}
@@ -327,8 +331,8 @@ public void TestMethod2()
327331 // space between closing brace and closing parenthesis should be reported by SA1009
328332 DiagnosticResult [ ] expected =
329333 {
330- Diagnostic ( ) . WithLocation ( 12 , 39 ) . WithArguments ( string . Empty , "preceded" ) ,
331- Diagnostic ( ) . WithLocation ( 14 , 39 ) . WithArguments ( string . Empty , "preceded" ) ,
334+ Diagnostic ( ) . WithLocation ( 0 ) . WithArguments ( string . Empty , "preceded" ) ,
335+ Diagnostic ( ) . WithLocation ( 1 ) . WithArguments ( string . Empty , "preceded" ) ,
332336 } ;
333337
334338 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -383,12 +387,12 @@ public async Task TestMissingTokenAsync()
383387 {
384388 string testCode = @"
385389class ClassName
386- {
390+ {{|#0:|}
387391" ;
388392
389393 DiagnosticResult [ ] expected =
390394 {
391- DiagnosticResult . CompilerError ( "CS1513" ) . WithMessage ( "} expected" ) . WithLocation ( 3 , 2 ) ,
395+ DiagnosticResult . CompilerError ( "CS1513" ) . WithMessage ( "} expected" ) . WithLocation ( 0 ) ,
392396 } ;
393397
394398 await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
0 commit comments