@@ -297,6 +297,82 @@ class MyAttribute : Attribute { }
297297 await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
298298 }
299299
300+ [ Fact ]
301+ public async Task TestMethodDeclarationAsync ( )
302+ {
303+ string testCode = @"
304+ class Container
305+ {
306+ void NonGenericType()
307+ {
308+ }
309+
310+ void TypeWithoutConstraints<T>()
311+ {
312+ }
313+
314+ void TypeWithOneConstraint<T>()
315+ where T : new()
316+ {
317+ }
318+
319+ void TypeWithMultipleConstraints1<T1, T2, T3>() where T1 : new()
320+ where T2 : new()
321+ where T3 : new()
322+ {
323+ }
324+
325+ void TypeWithMultipleConstraints2<T1, T2, T3>()
326+ where T1 : new()
327+ where T2 : new()
328+ where T3 : new()
329+ {
330+ }
331+ }
332+ " ;
333+ string fixedCode = @"
334+ class Container
335+ {
336+ void NonGenericType()
337+ {
338+ }
339+
340+ void TypeWithoutConstraints<T>()
341+ {
342+ }
343+
344+ void TypeWithOneConstraint<T>()
345+ where T : new()
346+ {
347+ }
348+
349+ void TypeWithMultipleConstraints1<T1, T2, T3>() where T1 : new()
350+ where T2 : new()
351+ where T3 : new()
352+ {
353+ }
354+
355+ void TypeWithMultipleConstraints2<T1, T2, T3>()
356+ where T1 : new()
357+ where T2 : new()
358+ where T3 : new()
359+ {
360+ }
361+ }
362+ " ;
363+
364+ DiagnosticResult [ ] expected =
365+ {
366+ this . CSharpDiagnostic ( ) . WithLocation ( 19 , 1 ) ,
367+ this . CSharpDiagnostic ( ) . WithLocation ( 25 , 1 ) ,
368+ this . CSharpDiagnostic ( ) . WithLocation ( 26 , 1 ) ,
369+ } ;
370+
371+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
372+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
373+ await this . VerifyCSharpFixAsync ( testCode , fixedCode , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
374+ }
375+
300376 [ Theory ]
301377 [ InlineData ( "class" , " { }" ) ]
302378 [ InlineData ( "void" , "() { }" ) ]
0 commit comments