@@ -1128,11 +1128,102 @@ public void TestMethod2()
11281128 await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
11291129 }
11301130
1131+ /// <summary>
1132+ /// Verifies that a base constructor call with the comma on the wrong line is handled properly.
1133+ /// This is a regression test for #1654.
1134+ /// </summary>
1135+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
1136+ [ Fact ]
1137+ public async Task VerifyBaseConstructorCallAsync ( )
1138+ {
1139+ var testCode = @"
1140+ abstract class BaseClass
1141+ {
1142+ protected BaseClass(int x, int y) { }
1143+ }
1144+
1145+ class ClassName : BaseClass
1146+ {
1147+ protected ClassName(int x, int y)
1148+ : base(
1149+ x
1150+ , y)
1151+ {
1152+ }
1153+ }
1154+ " ;
1155+ var fixedCode = @"
1156+ abstract class BaseClass
1157+ {
1158+ protected BaseClass(int x, int y) { }
1159+ }
1160+
1161+ class ClassName : BaseClass
1162+ {
1163+ protected ClassName(int x, int y)
1164+ : base(
1165+ x,
1166+ y)
1167+ {
1168+ }
1169+ }
1170+ " ;
1171+
1172+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 12 , 13 ) ;
1173+
1174+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
1175+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
1176+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
1177+ }
1178+
1179+ /// <summary>
1180+ /// Verifies that a this constructor call with the comma on the wrong line is handled properly.
1181+ /// </summary>
1182+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
1183+ [ Fact ]
1184+ public async Task VerifyThisConstructorCallAsync ( )
1185+ {
1186+ var testCode = @"
1187+ class ClassName
1188+ {
1189+ private ClassName(int x, int y) { }
1190+
1191+ protected ClassName(int x, int y, int z)
1192+ : this(
1193+ x
1194+ , y)
1195+ {
1196+ }
1197+ }
1198+ " ;
1199+ var fixedCode = @"
1200+ class ClassName
1201+ {
1202+ private ClassName(int x, int y) { }
1203+
1204+ protected ClassName(int x, int y, int z)
1205+ : this(
1206+ x,
1207+ y)
1208+ {
1209+ }
1210+ }
1211+ " ;
1212+
1213+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithLocation ( 9 , 13 ) ;
1214+
1215+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
1216+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
1217+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
1218+ }
1219+
1220+ /// <inheritdoc/>
11311221 protected override IEnumerable < DiagnosticAnalyzer > GetCSharpDiagnosticAnalyzers ( )
11321222 {
11331223 yield return new SA1113CommaMustBeOnSameLineAsPreviousParameter ( ) ;
11341224 }
11351225
1226+ /// <inheritdoc/>
11361227 protected override CodeFixProvider GetCSharpCodeFixProvider ( )
11371228 {
11381229 return new TokenSpacingCodeFixProvider ( ) ;
0 commit comments