@@ -101,6 +101,79 @@ class MyAttribute : Attribute {{ }}
101101 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
102102 }
103103
104+ [ Theory ]
105+ [ InlineData ( "class" ) ]
106+ [ InlineData ( "struct" ) ]
107+ [ InlineData ( "interface" ) ]
108+ public async Task TestTypeDeclarationConstraintClausesAsync ( string typeKind )
109+ {
110+ string testCode = $@ "
111+ { typeKind } NonGenericType
112+ {{
113+ }}
114+
115+ { typeKind } TypeWithoutConstraints<T>
116+ {{
117+ }}
118+
119+ { typeKind } TypeWithOneConstraint<T>
120+ where T : new()
121+ {{
122+ }}
123+
124+ { typeKind } TypeWithMultipleConstraints1<T1, T2, T3> where T1 : new()
125+ where T2 : new()
126+ where T3 : new()
127+ {{
128+ }}
129+
130+ { typeKind } TypeWithMultipleConstraints2<T1, T2, T3>
131+ where T1 : new()
132+ where T2 : new()
133+ where T3 : new()
134+ {{
135+ }}
136+ " ;
137+ string fixedCode = $@ "
138+ { typeKind } NonGenericType
139+ {{
140+ }}
141+
142+ { typeKind } TypeWithoutConstraints<T>
143+ {{
144+ }}
145+
146+ { typeKind } TypeWithOneConstraint<T>
147+ where T : new()
148+ {{
149+ }}
150+
151+ { typeKind } TypeWithMultipleConstraints1<T1, T2, T3> where T1 : new()
152+ where T2 : new()
153+ where T3 : new()
154+ {{
155+ }}
156+
157+ { typeKind } TypeWithMultipleConstraints2<T1, T2, T3>
158+ where T1 : new()
159+ where T2 : new()
160+ where T3 : new()
161+ {{
162+ }}
163+ " ;
164+
165+ DiagnosticResult [ ] expected =
166+ {
167+ this . CSharpDiagnostic ( ) . WithLocation ( 17 , 1 ) ,
168+ this . CSharpDiagnostic ( ) . WithLocation ( 23 , 1 ) ,
169+ this . CSharpDiagnostic ( ) . WithLocation ( 24 , 1 ) ,
170+ } ;
171+
172+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
173+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
174+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
175+ }
176+
104177 [ Fact ]
105178 public async Task TestBlockAsync ( )
106179 {
0 commit comments