|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules |
5 | 5 | { |
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
6 | 8 | using StyleCop.Analyzers.Test.CSharp8.SpacingRules; |
| 9 | + using Xunit; |
| 10 | + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< |
| 11 | + StyleCop.Analyzers.SpacingRules.SA1014OpeningGenericBracketsMustBeSpacedCorrectly, |
| 12 | + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; |
7 | 13 |
|
8 | 14 | public partial class SA1014CSharp9UnitTests : SA1014CSharp8UnitTests |
9 | 15 | { |
| 16 | + [Fact] |
| 17 | + [WorkItem(3970, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3970")] |
| 18 | + public async Task TestFunctionPointerOpeningBracketSpacingAsync() |
| 19 | + { |
| 20 | + var testCode = @"public class TestClass |
| 21 | +{ |
| 22 | + private unsafe delegate* {|#0:<|}int, void> field1; |
| 23 | + private unsafe delegate*{|#1:<|} int, void> field2; |
| 24 | + private unsafe delegate* unmanaged[Cdecl] {|#2:<|}int, void> field3; |
| 25 | +} |
| 26 | +"; |
| 27 | + |
| 28 | + var fixedCode = @"public class TestClass |
| 29 | +{ |
| 30 | + private unsafe delegate*<int, void> field1; |
| 31 | + private unsafe delegate*<int, void> field2; |
| 32 | + private unsafe delegate* unmanaged[Cdecl]<int, void> field3; |
| 33 | +} |
| 34 | +"; |
| 35 | + |
| 36 | + var expected = new[] |
| 37 | + { |
| 38 | + Diagnostic().WithArguments("preceded").WithLocation(0), |
| 39 | + Diagnostic().WithArguments("followed").WithLocation(1), |
| 40 | + Diagnostic().WithArguments("preceded").WithLocation(2), |
| 41 | + }; |
| 42 | + |
| 43 | + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); |
| 44 | + } |
10 | 45 | } |
11 | 46 | } |
0 commit comments