|
4 | 4 | namespace StyleCop.Analyzers.Test.LayoutRules |
5 | 5 | { |
6 | 6 | using System.Collections.Generic; |
7 | | - using System.Collections.Immutable; |
8 | 7 | using System.Threading; |
9 | 8 | using System.Threading.Tasks; |
10 | 9 | using Microsoft.CodeAnalysis; |
@@ -646,7 +645,66 @@ public void Bar(int i) |
646 | 645 | } |
647 | 646 | }"; |
648 | 647 |
|
649 | | - var fixedCode = @"using System.Diagnostics; |
| 648 | + var incrementalFixedCode = @"using System.Diagnostics; |
| 649 | +public class TypeName |
| 650 | +{ |
| 651 | + public void Bar(int i) |
| 652 | + { |
| 653 | + if (i == 0) |
| 654 | + Debug.Assert(true); |
| 655 | + else |
| 656 | + Debug.Assert(false);//8 |
| 657 | +
|
| 658 | +
|
| 659 | + if (i == 1) |
| 660 | + Debug.Assert(true); |
| 661 | + else if (i == 2) |
| 662 | + Debug.Assert(false);//10 |
| 663 | +
|
| 664 | +
|
| 665 | + if (i == 3) |
| 666 | + Debug.Assert(true); |
| 667 | + else if (i == 4) |
| 668 | + Debug.Assert(false);//14 |
| 669 | +
|
| 670 | +
|
| 671 | + if (i == 5) |
| 672 | + Debug.Assert(true); |
| 673 | + else if (i == 6) |
| 674 | + Debug.Assert(false); |
| 675 | + else |
| 676 | + Debug.Assert(false);//16 |
| 677 | +
|
| 678 | +
|
| 679 | + if (i == 7) |
| 680 | + if (i == 8) |
| 681 | + Debug.Assert(false); |
| 682 | + else |
| 683 | + Debug.Assert(false); |
| 684 | + else |
| 685 | + Debug.Assert(true);//18 |
| 686 | +
|
| 687 | +
|
| 688 | + if (i == 9) |
| 689 | + if (i == 10) |
| 690 | + Debug.Assert(false); |
| 691 | + else |
| 692 | + Debug.Assert(false); |
| 693 | + else |
| 694 | + Debug.Assert(true);//21 |
| 695 | +
|
| 696 | +
|
| 697 | + if (i == 11) if (i == 12) |
| 698 | + Debug.Assert(false); |
| 699 | + else |
| 700 | + Debug.Assert(false); |
| 701 | + else if (i == 13) |
| 702 | + Debug.Assert(true);//24 |
| 703 | +
|
| 704 | + } |
| 705 | +}"; |
| 706 | + |
| 707 | + var batchFixedCode = @"using System.Diagnostics; |
650 | 708 | public class TypeName |
651 | 709 | { |
652 | 710 | public void Bar(int i) |
@@ -710,27 +768,30 @@ public void Bar(int i) |
710 | 768 | { |
711 | 769 | this.CSharpDiagnostic().WithLocation(8, 14), |
712 | 770 | this.CSharpDiagnostic().WithLocation(10, 21), |
713 | | - this.CSharpDiagnostic().WithLocation(10, 58).WithSeverity(DiagnosticSeverity.Hidden), |
| 771 | + this.CSharpDiagnostic().WithLocation(10, 58), |
714 | 772 | this.CSharpDiagnostic().WithLocation(14, 26), |
715 | 773 | this.CSharpDiagnostic().WithLocation(16, 21), |
716 | | - this.CSharpDiagnostic().WithLocation(16, 58).WithSeverity(DiagnosticSeverity.Hidden), |
717 | | - this.CSharpDiagnostic().WithLocation(16, 84).WithSeverity(DiagnosticSeverity.Hidden), |
| 774 | + this.CSharpDiagnostic().WithLocation(16, 58), |
| 775 | + this.CSharpDiagnostic().WithLocation(16, 84), |
718 | 776 | this.CSharpDiagnostic().WithLocation(18, 21), |
719 | | - this.CSharpDiagnostic().WithLocation(18, 33).WithSeverity(DiagnosticSeverity.Hidden), |
720 | | - this.CSharpDiagnostic().WithLocation(18, 59).WithSeverity(DiagnosticSeverity.Hidden), |
721 | | - this.CSharpDiagnostic().WithLocation(18, 85).WithSeverity(DiagnosticSeverity.Hidden), |
722 | | - this.CSharpDiagnostic().WithLocation(21, 26).WithSeverity(DiagnosticSeverity.Hidden), |
723 | | - this.CSharpDiagnostic().WithLocation(21, 52).WithSeverity(DiagnosticSeverity.Hidden), |
| 777 | + this.CSharpDiagnostic().WithLocation(18, 33), |
| 778 | + this.CSharpDiagnostic().WithLocation(18, 59), |
| 779 | + this.CSharpDiagnostic().WithLocation(18, 85), |
| 780 | + this.CSharpDiagnostic().WithLocation(21, 26), |
| 781 | + this.CSharpDiagnostic().WithLocation(21, 52), |
724 | 782 | this.CSharpDiagnostic().WithLocation(21, 78), |
725 | 783 | this.CSharpDiagnostic().WithLocation(23, 22).WithSeverity(DiagnosticSeverity.Hidden), |
726 | 784 | this.CSharpDiagnostic().WithLocation(23, 35), |
727 | | - this.CSharpDiagnostic().WithLocation(24, 18).WithSeverity(DiagnosticSeverity.Hidden), |
| 785 | + this.CSharpDiagnostic().WithLocation(24, 18), |
728 | 786 | this.CSharpDiagnostic().WithLocation(24, 57), |
729 | 787 | }; |
730 | 788 |
|
| 789 | + DiagnosticResult incrementalFixExpected = this.CSharpDiagnostic().WithLocation(50, 22).WithSeverity(DiagnosticSeverity.Hidden); |
| 790 | + |
731 | 791 | await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
732 | | - await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
733 | | - await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false); |
| 792 | + await this.VerifyCSharpDiagnosticAsync(incrementalFixedCode, incrementalFixExpected, CancellationToken.None).ConfigureAwait(false); |
| 793 | + await this.VerifyCSharpDiagnosticAsync(batchFixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 794 | + await this.VerifyCSharpFixAsync(testCode, incrementalFixedCode, batchFixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false); |
734 | 795 | } |
735 | 796 |
|
736 | 797 | /// <summary> |
@@ -781,7 +842,7 @@ public void Bar(int i) |
781 | 842 | DiagnosticResult[] expected = |
782 | 843 | { |
783 | 844 | this.CSharpDiagnostic().WithLocation(6, 21), |
784 | | - this.CSharpDiagnostic().WithLocation(6, 46).WithSeverity(DiagnosticSeverity.Hidden), |
| 845 | + this.CSharpDiagnostic().WithLocation(6, 46), |
785 | 846 | }; |
786 | 847 |
|
787 | 848 | await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
@@ -880,7 +941,7 @@ public void Bar(int i) |
880 | 941 | DiagnosticResult[] expected = |
881 | 942 | { |
882 | 943 | this.CSharpDiagnostic().WithLocation(6, 21), |
883 | | - this.CSharpDiagnostic().WithLocation(6, 33).WithSeverity(DiagnosticSeverity.Hidden), |
| 944 | + this.CSharpDiagnostic().WithLocation(6, 33), |
884 | 945 | }; |
885 | 946 |
|
886 | 947 | await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
|
0 commit comments