Skip to content

Commit b6a1179

Browse files
committed
Update SA1019 to report violations for pointer member access
1 parent 1555129 commit b6a1179

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1019UnitTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ public unsafe void MethodName()
209209
x++ ?. ToString();
210210
x++ ?.ToString();
211211
x++?. ToString();
212+
213+
y-- -> ToString();
214+
y-- ->ToString();
215+
y---> ToString();
216+
217+
y++ -> ToString();
218+
y++ ->ToString();
219+
y++-> ToString();
212220
}
213221
}
214222
";
@@ -234,6 +242,14 @@ public unsafe void MethodName()
234242
x++?.ToString();
235243
x++?.ToString();
236244
x++?.ToString();
245+
246+
y--->ToString();
247+
y--->ToString();
248+
y--->ToString();
249+
250+
y++->ToString();
251+
y++->ToString();
252+
y++->ToString();
237253
}
238254
}
239255
";
@@ -258,6 +274,16 @@ public unsafe void MethodName()
258274
this.CSharpDiagnostic().WithLocation(20, 14).WithArguments(".", "followed"),
259275
this.CSharpDiagnostic().WithLocation(21, 13).WithArguments("?", "preceded"),
260276
this.CSharpDiagnostic().WithLocation(22, 13).WithArguments(".", "followed"),
277+
278+
this.CSharpDiagnostic().WithLocation(24, 13).WithArguments("->", "preceded"),
279+
this.CSharpDiagnostic().WithLocation(24, 13).WithArguments("->", "followed"),
280+
this.CSharpDiagnostic().WithLocation(25, 13).WithArguments("->", "preceded"),
281+
this.CSharpDiagnostic().WithLocation(26, 12).WithArguments("->", "followed"),
282+
283+
this.CSharpDiagnostic().WithLocation(28, 13).WithArguments("->", "preceded"),
284+
this.CSharpDiagnostic().WithLocation(28, 13).WithArguments("->", "followed"),
285+
this.CSharpDiagnostic().WithLocation(29, 13).WithArguments("->", "preceded"),
286+
this.CSharpDiagnostic().WithLocation(30, 12).WithArguments("->", "followed"),
261287
};
262288

263289
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1019MemberAccessSymbolsMustBeSpacedCorrectly.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context)
5959
HandleDotToken(context, token);
6060
break;
6161

62+
case SyntaxKind.MinusGreaterThanToken:
63+
HandleMemberAccessSymbol(context, token);
64+
break;
65+
6266
// This case handles the new ?. and ?[ operators
6367
case SyntaxKind.QuestionToken:
6468
HandleQuestionToken(context, token);

0 commit comments

Comments
 (0)