@@ -306,6 +306,121 @@ internal class BarAttribute : Attribute
306306 await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
307307 }
308308
309+ /// <summary>
310+ /// Regression test for issue 1879 (SA1133CodeFixProvider does only half the work), https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1879
311+ /// </summary>
312+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
313+ [ Fact ]
314+ public async Task TestFixAllAsync ( )
315+ {
316+ var testCode = @"
317+ namespace Stylecop_rc1_bug_repro
318+ {
319+ class Foo
320+ {
321+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
322+ public string Foo1{ get; set; }
323+
324+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
325+ public string Foo2{ get; set; }
326+
327+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
328+ public string Foo3 { get; set; }
329+
330+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
331+ public string Foo4{ get; set; }
332+
333+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
334+ public string Foo5{ get; set; }
335+
336+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
337+ public string Foo6{ get; set; }
338+
339+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
340+ public string Foo7{ get; set; }
341+
342+ [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
343+ public string Foo8{ get; set; }
344+
345+ }
346+ }
347+
348+ public class CanBeNullAttribute : System.Attribute { }
349+ public class UsedImplicitly : System.Attribute
350+ {
351+ public UsedImplicitly (ImplicitUseKindFlags flags) { }
352+ }
353+
354+ public enum ImplicitUseKindFlags { Assign }
355+ " ;
356+
357+ var fixedTestCode = @"
358+ namespace Stylecop_rc1_bug_repro
359+ {
360+ class Foo
361+ {
362+ [CanBeNull]
363+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
364+ public string Foo1{ get; set; }
365+
366+ [CanBeNull]
367+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
368+ public string Foo2{ get; set; }
369+
370+ [CanBeNull]
371+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
372+ public string Foo3 { get; set; }
373+
374+ [CanBeNull]
375+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
376+ public string Foo4{ get; set; }
377+
378+ [CanBeNull]
379+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
380+ public string Foo5{ get; set; }
381+
382+ [CanBeNull]
383+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
384+ public string Foo6{ get; set; }
385+
386+ [CanBeNull]
387+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
388+ public string Foo7{ get; set; }
389+
390+ [CanBeNull]
391+ [UsedImplicitly(ImplicitUseKindFlags.Assign)]
392+ public string Foo8{ get; set; }
393+
394+ }
395+ }
396+
397+ public class CanBeNullAttribute : System.Attribute { }
398+ public class UsedImplicitly : System.Attribute
399+ {
400+ public UsedImplicitly (ImplicitUseKindFlags flags) { }
401+ }
402+
403+ public enum ImplicitUseKindFlags { Assign }
404+ " ;
405+
406+ DiagnosticResult [ ] expected =
407+ {
408+ this . CSharpDiagnostic ( ) . WithLocation ( 6 , 21 ) ,
409+ this . CSharpDiagnostic ( ) . WithLocation ( 9 , 21 ) ,
410+ this . CSharpDiagnostic ( ) . WithLocation ( 12 , 21 ) ,
411+ this . CSharpDiagnostic ( ) . WithLocation ( 15 , 21 ) ,
412+ this . CSharpDiagnostic ( ) . WithLocation ( 18 , 21 ) ,
413+ this . CSharpDiagnostic ( ) . WithLocation ( 21 , 21 ) ,
414+ this . CSharpDiagnostic ( ) . WithLocation ( 24 , 21 ) ,
415+ this . CSharpDiagnostic ( ) . WithLocation ( 27 , 21 )
416+ } ;
417+
418+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
419+ await this . VerifyCSharpDiagnosticAsync ( fixedTestCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
420+ await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
421+ await this . VerifyCSharpFixAllFixAsync ( testCode , fixedTestCode , maxNumberOfIterations : 1 ) . ConfigureAwait ( false ) ;
422+ }
423+
309424 /// <inheritdoc/>
310425 protected override CodeFixProvider GetCSharpCodeFixProvider ( )
311426 {
0 commit comments