@@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp7.NamingRules
88 using Microsoft . CodeAnalysis . Testing ;
99 using StyleCop . Analyzers . Lightup ;
1010 using StyleCop . Analyzers . NamingRules ;
11- using StyleCop . Analyzers . Settings . ObjectModel ;
1211 using Xunit ;
1312 using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
1413 StyleCop . Analyzers . NamingRules . SA1316TupleElementNamesShouldUseCorrectCasing ,
@@ -170,6 +169,42 @@ public void TestMethod()
170169 await VerifyCSharpDiagnosticAsync ( LanguageVersionEx . CSharp7_1 , testCode , settings , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
171170 }
172171
172+ /// <summary>
173+ /// Validates the properly explicitly named tuple elements, even when using inferred tuple element names, will not produce diagnostics.
174+ /// </summary>
175+ /// <param name="settings">The test settings to use.</param>
176+ /// <param name="tupleElementName1">The expected tuple element name for the first field.</param>
177+ /// <param name="tupleElementName2">The expected tuple element name for the second field.</param>
178+ /// <param name="tupleInferred1">The name of the first tuple element that would be inferred if not given explicitly.</param>
179+ /// <param name="tupleInferred2">The name of the second tuple element that would be inferred if not given explicitly.</param>
180+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
181+ [ Theory ]
182+ [ InlineData ( CamelCaseInferredTestSettings , "elementName1" , "elementName2" , "ElementValue1" , "ElementValue2" ) ]
183+ [ InlineData ( PascalCaseInferredTestSettings , "ElementName1" , "ElementName2" , "elementValue1" , "elementValue2" ) ]
184+ public async Task ValidateProperCasedExplicitNamesEvenWithInferredTupleElementNamesAsync ( string settings , string tupleElementName1 , string tupleElementName2 , string tupleInferred1 , string tupleInferred2 )
185+ {
186+ var testCode = $@ "
187+ public class TestClass
188+ {{
189+ public void TestMethod1()
190+ {{
191+ var { tupleInferred1 } = 1;
192+ var { tupleInferred2 } = ""test"";
193+ var tuple = ({ tupleElementName1 } : { tupleInferred1 } , { tupleElementName2 } : { tupleInferred2 } );
194+ }}
195+
196+ public void TestMethod2()
197+ {{
198+ var { tupleInferred1 } = 1;
199+ var { tupleElementName2 } = ""test"";
200+ var tuple = ({ tupleElementName1 } : { tupleInferred1 } , { tupleElementName2 } );
201+ }}
202+ }}
203+ " ;
204+
205+ await VerifyCSharpDiagnosticAsync ( LanguageVersionEx . CSharp7_1 , testCode , settings , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
206+ }
207+
173208 /// <summary>
174209 /// Validates the improperly named tuple element names will produce the expected diagnostics.
175210 /// </summary>
0 commit comments