@@ -32,7 +32,7 @@ public async Task TestFunctionPointerParameterInvalidPrecedingSpaceAsync()
3232 {
3333 var testCode = @"public class TestClass
3434{
35- unsafe delegate*<int * > FuncPtr;
35+ unsafe delegate*<int {|#0:*|} > FuncPtr;
3636}
3737" ;
3838
@@ -42,7 +42,7 @@ public async Task TestFunctionPointerParameterInvalidPrecedingSpaceAsync()
4242}
4343" ;
4444
45- var expected = Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 3 , 26 ) ;
45+ var expected = Diagnostic ( DescriptorNotPreceded ) . WithLocation ( 0 ) ;
4646 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
4747 }
4848
@@ -51,7 +51,7 @@ public async Task TestFunctionPointerParameterInvalidTrailingSpaceAsync()
5151 {
5252 var testCode = @"public class TestClass
5353{
54- unsafe delegate*<int* > FuncPtr;
54+ unsafe delegate*<int{|#0:*|} > FuncPtr;
5555}
5656" ;
5757
@@ -61,7 +61,107 @@ public async Task TestFunctionPointerParameterInvalidTrailingSpaceAsync()
6161}
6262" ;
6363
64- var expected = Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 3 , 25 ) ;
64+ var expected = Diagnostic ( DescriptorNotFollowed ) . WithLocation ( 0 ) ;
65+ await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
66+ }
67+
68+ [ Fact ]
69+ public async Task TestFunctionPointerTypeValidSpacingAsync ( )
70+ {
71+ var testCode = @"public class TestClass
72+ {
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;
86+ }
87+ " ;
88+
89+ var fixedCode = @"public class TestClass
90+ {
91+ unsafe delegate*<int*> FuncPtr;
92+ }
93+ " ;
94+
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+ " ;
163+
164+ var expected = Diagnostic ( DescriptorFollowed ) . WithLocation ( 0 ) ;
65165 await VerifyCSharpFixAsync ( testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
66166 }
67167 }
0 commit comments