@@ -165,6 +165,54 @@ public void TestMethod()
165165 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
166166 }
167167
168+ /// <summary>
169+ /// Verifies that a combination of attributes without parameters will produce the required diagnostics.
170+ /// </summary>
171+ /// <param name="before">The code part before the code fix.</param>
172+ /// <param name="after">The code part after the code fix.</param>
173+ /// <param name="line">The line on which the diagnostic is expected.</param>
174+ /// <param name="column">The column on which the diagnostic is expected.</param>
175+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
176+ [ Theory ]
177+ [ InlineData ( "[Foo]\r \n [Bar, Car]" , "[Foo]\r \n [Bar]\r \n [Car]" , 3 , 7 ) ]
178+ [ InlineData ( "[Foo, Bar]\r \n [Car]" , "[Foo]\r \n [Bar]\r \n [Car]" , 2 , 7 ) ]
179+ [ InlineData ( "[Foo]\r \n [Bar, Car]\r \n [Ear]" , "[Foo]\r \n [Bar]\r \n [Car]\r \n [Ear]" , 3 , 7 ) ]
180+ public async Task VerifyAttributeCombinationsWithoutParametersAreHandledCorrectlyAsync ( string before , string after , int line , int column )
181+ {
182+ var testCode = @"using System;
183+ {0}
184+ public class TestClass
185+ {{
186+ }}
187+
188+ public class Foo : Attribute
189+ {{
190+ }}
191+
192+ public class Bar : Attribute
193+ {{
194+ }}
195+
196+ public class Car : Attribute
197+ {{
198+ }}
199+
200+ public class Ear : Attribute
201+ {{
202+ }}" ;
203+ var codeBefore = string . Format ( testCode , before ) ;
204+ var codeAfter = string . Format ( testCode , after ) ;
205+
206+ DiagnosticResult [ ] expected =
207+ {
208+ this . CSharpDiagnostic ( ) . WithLocation ( line , column )
209+ } ;
210+
211+ await this . VerifyCSharpDiagnosticAsync ( codeBefore , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
212+ await this . VerifyCSharpDiagnosticAsync ( codeAfter , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
213+ await this . VerifyCSharpFixAsync ( codeBefore , codeAfter ) . ConfigureAwait ( false ) ;
214+ }
215+
168216 /// <summary>
169217 /// Regression test for issue 1878 (SA1133CodeFixProvider crash), https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1878
170218 /// Fixing exception "Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.AttributeSyntax'."
0 commit comments