@@ -978,5 +978,65 @@ public void TestMethod(params (string name, string value)[] options)
978978
979979 await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
980980 }
981+
982+ [ Fact ]
983+ [ WorkItem ( 3117 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3117" ) ]
984+ public async Task TestTupleParameterAttributesAsync ( )
985+ {
986+ var testCode = @"
987+ namespace TestNamespace
988+ {
989+ class NotNullAttribute : System.Attribute { }
990+ class CustomAttribute : System.Attribute { }
991+
992+ class TestClass
993+ {
994+ void TestMethod1([NotNull] (string, string) tuple) { }
995+
996+ void TestMethod2([NotNull, Custom] (string, string) tuple) { }
997+
998+ void TestMethod3([NotNull][Custom] (string, string) tuple) { }
999+
1000+ void TestMethod4([NotNull]{|#0:(|}string, string) tuple) { }
1001+
1002+ void TestMethod5([NotNull, Custom]{|#1:(|}string, string) tuple) { }
1003+
1004+ void TestMethod6([NotNull][Custom]{|#2:(|}string, string) tuple) { }
1005+ }
1006+ }
1007+ " ;
1008+
1009+ var fixedCode = @"
1010+ namespace TestNamespace
1011+ {
1012+ class NotNullAttribute : System.Attribute { }
1013+ class CustomAttribute : System.Attribute { }
1014+
1015+ class TestClass
1016+ {
1017+ void TestMethod1([NotNull] (string, string) tuple) { }
1018+
1019+ void TestMethod2([NotNull, Custom] (string, string) tuple) { }
1020+
1021+ void TestMethod3([NotNull][Custom] (string, string) tuple) { }
1022+
1023+ void TestMethod4([NotNull] (string, string) tuple) { }
1024+
1025+ void TestMethod5([NotNull, Custom] (string, string) tuple) { }
1026+
1027+ void TestMethod6([NotNull][Custom] (string, string) tuple) { }
1028+ }
1029+ }
1030+ " ;
1031+
1032+ DiagnosticResult [ ] expectedDiagnostics =
1033+ {
1034+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 0 ) ,
1035+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 1 ) ,
1036+ Diagnostic ( DescriptorPreceded ) . WithLocation ( 2 ) ,
1037+ } ;
1038+
1039+ await VerifyCSharpFixAsync ( testCode , expectedDiagnostics , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
1040+ }
9811041 }
9821042}
0 commit comments