1
1
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2
2
// Licensed under the MIT License. See LICENSE in the project root for license information.
3
3
4
- #nullable disable
5
-
6
4
namespace StyleCop . Analyzers . Test . SpacingRules
7
5
{
8
6
using System . Threading ;
@@ -54,15 +52,17 @@ public async Task TestStringInterpolationAsync()
54
52
{
55
53
public class TestClass
56
54
{
57
- public void TestMethod()
55
+ public void TestMethod(int a, int b )
58
56
{
59
57
var test = 2;
60
58
var x = $""{test}"";
61
59
x = $""{test}"";
62
60
x = $""({test})"";
63
61
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:}|}"";
66
66
}
67
67
}
68
68
}
@@ -72,7 +72,7 @@ public void TestMethod()
72
72
{
73
73
public class TestClass
74
74
{
75
- public void TestMethod()
75
+ public void TestMethod(int a, int b )
76
76
{
77
77
var test = 2;
78
78
var x = $""{test}"";
@@ -81,15 +81,19 @@ public void TestMethod()
81
81
x = $""({test} )"";
82
82
x = $""{test}"";
83
83
x = $""{test} "";
84
+ x = $""{new { a, b }}"";
85
+ x = $""{new { a, b }}"";
84
86
}
85
87
}
86
88
}
87
89
" ;
88
90
89
91
DiagnosticResult [ ] expected =
90
92
{
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" ) ,
93
97
} ;
94
98
95
99
await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -107,7 +111,7 @@ public async Task TestPropertyDeclarationAsync()
107
111
public class TestClass
108
112
{
109
113
public int TestProperty1 { get; set; }
110
- public int TestProperty2 { get; set;}
114
+ public int TestProperty2 { get; set;{|#0:}| }
111
115
}
112
116
}
113
117
" ;
@@ -124,7 +128,7 @@ public class TestClass
124
128
125
129
DiagnosticResult [ ] expected =
126
130
{
127
- Diagnostic ( ) . WithLocation ( 6 , 45 ) . WithArguments ( string . Empty , "preceded" ) ,
131
+ Diagnostic ( ) . WithLocation ( 0 ) . WithArguments ( string . Empty , "preceded" ) ,
128
132
} ;
129
133
130
134
await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -146,9 +150,9 @@ public class TestClass
146
150
public void TestMethod()
147
151
{
148
152
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:}| };
152
156
}
153
157
}
154
158
}
@@ -173,12 +177,12 @@ public void TestMethod()
173
177
174
178
DiagnosticResult [ ] expected =
175
179
{
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" ) ,
182
186
} ;
183
187
184
188
await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -297,9 +301,9 @@ public void TestMethod1(object[] a)
297
301
public void TestMethod2()
298
302
{
299
303
TestMethod1(new object[] { });
300
- TestMethod1(new object[] {});
304
+ TestMethod1(new object[] {{|#0:}| });
301
305
TestMethod1(new object[] { } );
302
- TestMethod1(new object[] {} );
306
+ TestMethod1(new object[] {{|#1:}| } );
303
307
}
304
308
}
305
309
}
@@ -327,8 +331,8 @@ public void TestMethod2()
327
331
// space between closing brace and closing parenthesis should be reported by SA1009
328
332
DiagnosticResult [ ] expected =
329
333
{
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" ) ,
332
336
} ;
333
337
334
338
await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -383,12 +387,12 @@ public async Task TestMissingTokenAsync()
383
387
{
384
388
string testCode = @"
385
389
class ClassName
386
- {
390
+ {{|#0:|}
387
391
" ;
388
392
389
393
DiagnosticResult [ ] expected =
390
394
{
391
- DiagnosticResult . CompilerError ( "CS1513" ) . WithMessage ( "} expected" ) . WithLocation ( 3 , 2 ) ,
395
+ DiagnosticResult . CompilerError ( "CS1513" ) . WithMessage ( "} expected" ) . WithLocation ( 0 ) ,
392
396
} ;
393
397
394
398
await VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
0 commit comments