@@ -223,6 +223,56 @@ public async Task TestTypeDeclarationConstraintClausesAsync(string typeKind)
223223 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
224224 }
225225
226+ [ Theory ]
227+ [ InlineData ( "class" , "int" , " { }" ) ]
228+ [ InlineData ( "struct" , "int" , " { }" ) ]
229+ [ InlineData ( "interface" , "event System.EventHandler" , ";" ) ]
230+ public async Task TestTypeDeclarationMembersAsync ( string typeKind , string fieldType , string methodBody )
231+ {
232+ string testCode = $@ "
233+ { typeKind } Container1
234+ {{
235+ { fieldType } X1;
236+ int Y1 {{ get; }}
237+ void Z1(){ methodBody }
238+ }}
239+
240+ { typeKind } Container2
241+ {{
242+ { fieldType } X2;
243+ int Y2 {{ get; }}
244+ void Z2(){ methodBody }
245+ }}
246+ " ;
247+ string fixedCode = $@ "
248+ { typeKind } Container1
249+ {{
250+ { fieldType } X1;
251+ int Y1 {{ get; }}
252+ void Z1(){ methodBody }
253+ }}
254+
255+ { typeKind } Container2
256+ {{
257+ { fieldType } X2;
258+ int Y2 {{ get; }}
259+ void Z2(){ methodBody }
260+ }}
261+ " ;
262+
263+ DiagnosticResult [ ] expected =
264+ {
265+ this . CSharpDiagnostic ( ) . WithLocation ( 5 , 1 ) ,
266+ this . CSharpDiagnostic ( ) . WithLocation ( 6 , 1 ) ,
267+ this . CSharpDiagnostic ( ) . WithLocation ( 12 , 1 ) ,
268+ this . CSharpDiagnostic ( ) . WithLocation ( 13 , 1 ) ,
269+ } ;
270+
271+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
272+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
273+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
274+ }
275+
226276 /// <summary>
227277 /// This test demonstrates the behavior of SA1137 and its code fix with respect to documentation comments.
228278 /// Currently both operations ignore documentation comments, but in the future the implementation may be updated
0 commit comments