@@ -20,6 +20,89 @@ namespace StyleCop.Analyzers.Test.LayoutRules
2020 /// </remarks>
2121 public partial class SA1500UnitTests : CodeFixVerifier
2222 {
23+ /// <summary>
24+ /// Verifies that a complex multiple fix scenario is handled correctly.
25+ /// </summary>
26+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
27+ [ Fact ]
28+ [ WorkItem ( 2566 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2566" ) ]
29+ public async Task VerifyFixAllAsync ( )
30+ {
31+ var testCode = @"using System;
32+ public class TestClass
33+ {
34+ public static void Sample()
35+ {
36+ try {
37+ if (false) {
38+ return;
39+ } else if (false) {
40+ return;
41+ } else {
42+ return;
43+ }
44+ } catch (Exception) {
45+ } catch {
46+ } finally {
47+ }
48+ }
49+ }
50+ " ;
51+
52+ var fixedTestCode = @"using System;
53+ public class TestClass
54+ {
55+ public static void Sample()
56+ {
57+ try
58+ {
59+ if (false)
60+ {
61+ return;
62+ }
63+ else if (false)
64+ {
65+ return;
66+ }
67+ else
68+ {
69+ return;
70+ }
71+ }
72+ catch (Exception)
73+ {
74+ }
75+ catch
76+ {
77+ }
78+ finally
79+ {
80+ }
81+ }
82+ }
83+ " ;
84+
85+ DiagnosticResult [ ] expectedDiagnostics =
86+ {
87+ this . CSharpDiagnostic ( ) . WithLocation ( 6 , 13 ) ,
88+ this . CSharpDiagnostic ( ) . WithLocation ( 7 , 24 ) ,
89+ this . CSharpDiagnostic ( ) . WithLocation ( 9 , 13 ) ,
90+ this . CSharpDiagnostic ( ) . WithLocation ( 9 , 31 ) ,
91+ this . CSharpDiagnostic ( ) . WithLocation ( 11 , 13 ) ,
92+ this . CSharpDiagnostic ( ) . WithLocation ( 11 , 20 ) ,
93+ this . CSharpDiagnostic ( ) . WithLocation ( 14 , 9 ) ,
94+ this . CSharpDiagnostic ( ) . WithLocation ( 14 , 29 ) ,
95+ this . CSharpDiagnostic ( ) . WithLocation ( 15 , 9 ) ,
96+ this . CSharpDiagnostic ( ) . WithLocation ( 15 , 17 ) ,
97+ this . CSharpDiagnostic ( ) . WithLocation ( 16 , 9 ) ,
98+ this . CSharpDiagnostic ( ) . WithLocation ( 16 , 19 ) ,
99+ } ;
100+
101+ await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostics , CancellationToken . None ) . ConfigureAwait ( false ) ;
102+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
103+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
104+ }
105+
23106 /// <inheritdoc/>
24107 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
25108 {
0 commit comments