Skip to content

Commit c372210

Browse files
committed
Completely rewrite SA1027 using included/excluded spans analysis
1 parent 8076780 commit c372210

3 files changed

Lines changed: 247 additions & 86 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UnitTests.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public class Foo
125125
this.CSharpDiagnostic().WithLocation(1, 1),
126126
this.CSharpDiagnostic().WithLocation(1, 5),
127127
this.CSharpDiagnostic().WithLocation(2, 1),
128-
this.CSharpDiagnostic().WithLocation(2, 5),
128+
this.CSharpDiagnostic().WithLocation(2, 9),
129129
this.CSharpDiagnostic().WithLocation(3, 1),
130130
this.CSharpDiagnostic().WithLocation(3, 5),
131131
this.CSharpDiagnostic().WithLocation(4, 1),
@@ -175,7 +175,8 @@ public async Task TestInvalidTabsInCommentsAsync()
175175
this.CSharpDiagnostic().WithLocation(3, 1),
176176
this.CSharpDiagnostic().WithLocation(4, 1),
177177
this.CSharpDiagnostic().WithLocation(5, 1),
178-
this.CSharpDiagnostic().WithLocation(5, 5),
178+
this.CSharpDiagnostic().WithLocation(5, 7),
179+
this.CSharpDiagnostic().WithLocation(5, 15),
179180
this.CSharpDiagnostic().WithLocation(7, 1),
180181
this.CSharpDiagnostic().WithLocation(8, 1),
181182
this.CSharpDiagnostic().WithLocation(9, 1),
@@ -220,7 +221,10 @@ Comment 2
220221
this.CSharpDiagnostic().WithLocation(3, 1),
221222
this.CSharpDiagnostic().WithLocation(4, 1),
222223
this.CSharpDiagnostic().WithLocation(5, 1),
223-
this.CSharpDiagnostic().WithLocation(5, 5),
224+
this.CSharpDiagnostic().WithLocation(6, 1),
225+
this.CSharpDiagnostic().WithLocation(6, 11),
226+
this.CSharpDiagnostic().WithLocation(7, 1),
227+
this.CSharpDiagnostic().WithLocation(8, 1),
224228
this.CSharpDiagnostic().WithLocation(9, 1),
225229
this.CSharpDiagnostic().WithLocation(10, 1),
226230
};

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UseTabsUnitTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public async Task TestInvalidTabsInDocumentationCommentsAsync()
127127
this.CSharpDiagnostic().WithLocation(1, 1),
128128
this.CSharpDiagnostic().WithLocation(1, 8),
129129
this.CSharpDiagnostic().WithLocation(2, 1),
130-
this.CSharpDiagnostic().WithLocation(2, 8),
130+
this.CSharpDiagnostic().WithLocation(2, 12),
131131
this.CSharpDiagnostic().WithLocation(3, 1),
132132
this.CSharpDiagnostic().WithLocation(3, 8),
133133
this.CSharpDiagnostic().WithLocation(4, 1),
@@ -177,7 +177,8 @@ public async Task TestInvalidTabsInCommentsAsync()
177177
this.CSharpDiagnostic().WithLocation(3, 1),
178178
this.CSharpDiagnostic().WithLocation(4, 1),
179179
this.CSharpDiagnostic().WithLocation(5, 1),
180-
this.CSharpDiagnostic().WithLocation(5, 11),
180+
this.CSharpDiagnostic().WithLocation(5, 13),
181+
this.CSharpDiagnostic().WithLocation(5, 21),
181182
this.CSharpDiagnostic().WithLocation(7, 1),
182183
this.CSharpDiagnostic().WithLocation(8, 1),
183184
this.CSharpDiagnostic().WithLocation(9, 1),
@@ -209,9 +210,9 @@ public async Task TestInvalidTabsInMultiLineCommentsAsync()
209210
"\t\tpublic void Bar()\r\n" +
210211
"\t\t{\r\n" +
211212
"\t\t\t/*\r\n" +
212-
" Comment 1\r\n" +
213-
" Comment 2\r\n" +
214-
" */\r\n" +
213+
"\t\t\tComment 1\r\n" +
214+
"\t\t\tComment 2\r\n" +
215+
"\t\t\t*/\r\n" +
215216
"\t\t}\r\n" +
216217
"\t}\r\n";
217218

@@ -222,7 +223,10 @@ public async Task TestInvalidTabsInMultiLineCommentsAsync()
222223
this.CSharpDiagnostic().WithLocation(3, 1),
223224
this.CSharpDiagnostic().WithLocation(4, 1),
224225
this.CSharpDiagnostic().WithLocation(5, 1),
225-
this.CSharpDiagnostic().WithLocation(5, 11),
226+
this.CSharpDiagnostic().WithLocation(6, 1),
227+
this.CSharpDiagnostic().WithLocation(6, 17),
228+
this.CSharpDiagnostic().WithLocation(7, 1),
229+
this.CSharpDiagnostic().WithLocation(8, 1),
226230
this.CSharpDiagnostic().WithLocation(9, 1),
227231
this.CSharpDiagnostic().WithLocation(10, 1),
228232
};

0 commit comments

Comments
 (0)