@@ -276,6 +276,121 @@ internal class BarAttribute : Attribute
276276 await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
277277 }
278278
279+ /// <summary>
280+ /// Regression test for issue 1879 (SA1133CodeFixProvider does only half the work), https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1879
281+ /// </summary>
282+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
283+ [ Fact ]
284+ public async Task TestFixAllAsync ( )
285+ {
286+ var testCode = @"
287+ namespace Stylecop_rc1_bug_repro
288+ {
289+ class Foo
290+ {
291+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
292+ public string Foo1{ get; set; }
293+
294+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
295+ public string Foo2{ get; set; }
296+
297+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
298+ public string Foo3 { get; set; }
299+
300+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
301+ public string Foo4{ get; set; }
302+
303+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
304+ public string Foo5{ get; set; }
305+
306+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
307+ public string Foo6{ get; set; }
308+
309+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
310+ public string Foo7{ get; set; }
311+
312+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
313+ public string Foo8{ get; set; }
314+
315+ }
316+ }
317+
318+ public class CanBeNullAttribute : System.Attribute { }
319+ public class UsedImplicitly : System.Attribute
320+ {
321+ public UsedImplicitly (ImplicitUseKindFlags flags) { }
322+ }
323+
324+ public enum ImplicitUseKindFlags { Assign }
325+ " ;
326+
327+ var fixedTestCode = @"
328+ namespace Stylecop_rc1_bug_repro
329+ {
330+ class Foo
331+ {
332+ [CanBeNull]
333+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
334+ public string Foo1{ get; set; }
335+
336+ [CanBeNull]
337+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
338+ public string Foo2{ get; set; }
339+
340+ [CanBeNull]
341+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
342+ public string Foo3 { get; set; }
343+
344+ [CanBeNull]
345+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
346+ public string Foo4{ get; set; }
347+
348+ [CanBeNull]
349+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
350+ public string Foo5{ get; set; }
351+
352+ [CanBeNull]
353+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
354+ public string Foo6{ get; set; }
355+
356+ [CanBeNull]
357+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
358+ public string Foo7{ get; set; }
359+
360+ [CanBeNull]
361+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
362+ public string Foo8{ get; set; }
363+
364+ }
365+ }
366+
367+ public class CanBeNullAttribute : System.Attribute { }
368+ public class UsedImplicitly : System.Attribute
369+ {
370+ public UsedImplicitly (ImplicitUseKindFlags flags) { }
371+ }
372+
373+ public enum ImplicitUseKindFlags { Assign }
374+ " ;
375+
376+ DiagnosticResult [ ] expected =
377+ {
378+ this . CSharpDiagnostic ( ) . WithLocation ( 6 , 21 ) ,
379+ this . CSharpDiagnostic ( ) . WithLocation ( 9 , 21 ) ,
380+ this . CSharpDiagnostic ( ) . WithLocation ( 12 , 21 ) ,
381+ this . CSharpDiagnostic ( ) . WithLocation ( 15 , 21 ) ,
382+ this . CSharpDiagnostic ( ) . WithLocation ( 18 , 21 ) ,
383+ this . CSharpDiagnostic ( ) . WithLocation ( 21 , 21 ) ,
384+ this . CSharpDiagnostic ( ) . WithLocation ( 24 , 21 ) ,
385+ this . CSharpDiagnostic ( ) . WithLocation ( 27 , 21 )
386+ } ;
387+
388+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
389+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
390+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
391+ await this . VerifyCSharpFixAllFixAsync ( testCode , fixedTestCode , maxNumberOfIterations : 1 ) . ConfigureAwait ( false ) ;
392+ }
393+
279394 /// <inheritdoc/>
280395 protected override CodeFixProvider GetCSharpCodeFixProvider ( )
281396 {
0 commit comments