@@ -401,8 +401,8 @@ public void MethodName()
401401 }
402402
403403 [ Fact ]
404- [ WorkItem ( 1343 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1343 " ) ]
405- public async Task TestLambdaParameterMultipleUnderscoresAsync ( )
404+ [ WorkItem ( 1606 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1606 " ) ]
405+ public async Task TestLambdaParameterNamedDoubleUnderscoreAsync ( )
406406 {
407407 var testCode = @"public class TypeName
408408{
@@ -414,11 +414,49 @@ public void MethodName()
414414 }
415415}" ;
416416
417+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
418+ }
419+
420+ /// <summary>
421+ /// Verifies this diagnostic does not check whether or not a parameter named <c>__</c> is being used.
422+ /// </summary>
423+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
424+ [ Fact ]
425+ [ WorkItem ( 1606 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1606" ) ]
426+ public async Task TestLambdaParameterNamedDoubleUnderscoreUsageAsync ( )
427+ {
428+ var testCode = @"public class TypeName
429+ {
430+ public void MethodName()
431+ {
432+ System.Func<int, int> function1 = __ => __;
433+ System.Func<int, int> function2 = (__) => __;
434+ System.Func<int, int> function3 = delegate(int __) { return __; };
435+ }
436+ }" ;
437+
438+ await this . VerifyCSharpDiagnosticAsync ( testCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
439+ }
440+
441+ [ Fact ]
442+ [ WorkItem ( 1343 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1343" ) ]
443+ public async Task TestLambdaParameterWithThreeUnderscoresAsync ( )
444+ {
445+ var testCode = @"public class TypeName
446+ {
447+ public void MethodName()
448+ {
449+ System.Action<int> action1 = ___ => { };
450+ System.Action<int> action2 = (___) => { };
451+ System.Action<int> action3 = delegate(int ___) { };
452+ }
453+ }" ;
454+
417455 DiagnosticResult [ ] expected =
418456 {
419- this . CSharpDiagnostic ( ) . WithArguments ( "__ " ) . WithLocation ( 5 , 38 ) ,
420- this . CSharpDiagnostic ( ) . WithArguments ( "__ " ) . WithLocation ( 6 , 39 ) ,
421- this . CSharpDiagnostic ( ) . WithArguments ( "__ " ) . WithLocation ( 7 , 51 ) ,
457+ this . CSharpDiagnostic ( ) . WithArguments ( "___ " ) . WithLocation ( 5 , 38 ) ,
458+ this . CSharpDiagnostic ( ) . WithArguments ( "___ " ) . WithLocation ( 6 , 39 ) ,
459+ this . CSharpDiagnostic ( ) . WithArguments ( "___ " ) . WithLocation ( 7 , 51 ) ,
422460 } ;
423461 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
424462 await this . VerifyCSharpFixAsync ( testCode , testCode ) . ConfigureAwait ( false ) ;
@@ -439,6 +477,21 @@ public void MethodName(int _)
439477 await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
440478 }
441479
480+ [ Fact ]
481+ [ WorkItem ( 1606 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1606" ) ]
482+ public async Task TestMethodParameterNamedDoubleUnderscoreAsync ( )
483+ {
484+ var testCode = @"public class TypeName
485+ {
486+ public void MethodName(int __)
487+ {
488+ }
489+ }" ;
490+
491+ DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "__" ) . WithLocation ( 3 , 32 ) ;
492+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
493+ }
494+
442495 [ Fact ]
443496 [ WorkItem ( 1529 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1529" ) ]
444497 public async Task TestInheritedInterfacesWithOverloadedMembersAsync ( )
0 commit comments