@@ -16,152 +16,60 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
1616 public class SA1023CSharp9UnitTests : SA1023CSharp8UnitTests
1717 {
1818 [ Fact ]
19- public async Task TestFunctionPointerParameterValidSpacingAsync ( )
19+ public async Task TestFunctionPointerParameterInvalidSpacingAsync ( )
2020 {
2121 var testCode = @"public class TestClass
2222{
23- unsafe delegate*<int*> FuncPtr;
24- }
25- " ;
26-
27- await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
28- }
29-
30- [ Fact ]
31- public async Task TestFunctionPointerParameterInvalidPrecedingSpaceAsync ( )
32- {
33- var testCode = @"public class TestClass
34- {
35- unsafe delegate*<int {|#0:*|}> FuncPtr;
23+ unsafe delegate*<int {|#0:*|}> FuncPtr1;
24+ unsafe delegate*<int{|#1:*|} > FuncPtr2;
3625}
3726" ;
3827
3928 var fixedCode = @"public class TestClass
4029{
41- unsafe delegate*<int*> FuncPtr;
30+ unsafe delegate*<int*> FuncPtr1;
31+ unsafe delegate*<int*> FuncPtr2;
4232}
4333" ;
4434
45- var expected = Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ;
46- await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
47- }
48-
49- [ Fact ]
50- public async Task TestFunctionPointerParameterInvalidTrailingSpaceAsync ( )
51- {
52- var testCode = @"public class TestClass
53- {
54- unsafe delegate*<int{|#0:*|} > FuncPtr;
55- }
56- " ;
35+ var expected = new [ ]
36+ {
37+ Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ,
38+ Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 1 ) ,
39+ } ;
5740
58- var fixedCode = @"public class TestClass
59- {
60- unsafe delegate*<int*> FuncPtr;
61- }
62- " ;
63-
64- var expected = Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 0 ) ;
6541 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
6642 }
6743
6844 [ Fact ]
69- public async Task TestFunctionPointerTypeValidSpacingAsync ( )
45+ public async Task TestFunctionPointerTypeInvalidSpacingAsync ( )
7046 {
7147 var testCode = @"public class TestClass
7248{
73- unsafe delegate*<int*> FuncPtr;
74- }
75- " ;
76-
77- await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
78- }
79-
80- [ Fact ]
81- public async Task TestFunctionPointerTypeInvalidPrecedingSpaceAsync ( )
82- {
83- var testCode = @"public class TestClass
84- {
85- unsafe delegate {|#0:*|}<int*> FuncPtr;
49+ unsafe delegate {|#0:*|}<int*> FuncPtr1;
50+ unsafe delegate{|#1:*|} <int*> FuncPtr2;
51+ unsafe delegate {|#2:*|} managed<int*> FuncPtr3;
52+ unsafe delegate{|#3:*|}managed<int*> FuncPtr4;
8653}
8754" ;
8855
8956 var fixedCode = @"public class TestClass
9057{
91- unsafe delegate*<int*> FuncPtr;
58+ unsafe delegate*<int*> FuncPtr1;
59+ unsafe delegate*<int*> FuncPtr2;
60+ unsafe delegate* managed<int*> FuncPtr3;
61+ unsafe delegate* managed<int*> FuncPtr4;
9262}
9363" ;
9464
95- var expected = Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ;
96- await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
97- }
98-
99- [ Fact ]
100- public async Task TestFunctionPointerTypeInvalidTrailingSpaceAsync ( )
101- {
102- var testCode = @"public class TestClass
103- {
104- unsafe delegate{|#0:*|} <int*> FuncPtr;
105- }
106- " ;
107-
108- var fixedCode = @"public class TestClass
109- {
110- unsafe delegate*<int*> FuncPtr;
111- }
112- " ;
113-
114- var expected = Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 0 ) ;
115- await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
116- }
117-
118- [ Fact ]
119- public async Task TestFunctionPointerTypeWithCallingConventionValidSpacingAsync ( )
120- {
121- var testCode = @"public class TestClass
122- {
123- unsafe delegate* managed<int*> FuncPtr;
124- }
125- " ;
126-
127- await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
128- }
129-
130- [ Fact ]
131- public async Task TestFunctionPointerTypeWithCallingConventionInvalidPrecedingSpaceAsync ( )
132- {
133- var testCode = @"public class TestClass
134- {
135- unsafe delegate {|#0:*|} managed<int*> FuncPtr;
136- }
137- " ;
138-
139- var fixedCode = @"public class TestClass
140- {
141- unsafe delegate* managed<int*> FuncPtr;
142- }
143- " ;
144-
145- var expected = Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ;
146- await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
147- }
148-
149- [ Fact ]
150- public async Task TestFunctionPointerTypeWithCallingConventionMissingTrailingSpaceAsync ( )
151- {
152- var testCode = @"public class TestClass
153- {
154- unsafe delegate{|#0:*|}managed<int*> FuncPtr;
155- }
156- " ;
157-
158- var fixedCode = @"public class TestClass
159- {
160- unsafe delegate* managed<int*> FuncPtr;
161- }
162- " ;
65+ var expected = new [ ]
66+ {
67+ Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ,
68+ Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 1 ) ,
69+ Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 2 ) ,
70+ Diagnostic ( DescriptorFollowed ) . WithLocation ( 3 ) ,
71+ } ;
16372
164- var expected = Diagnostic ( DescriptorFollowed ) . WithLocation ( 0 ) ;
16573 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
16674 }
16775 }
0 commit comments