diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs index cfabeb4ab..8e42a63ad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs @@ -115,18 +115,18 @@ private static void CheckName(SyntaxNodeAnalysisContext context, StyleCopSetting var firstCharacterIsLower = char.IsLower(tupleElementName[0]); bool reportDiagnostic; - string fixedName; + char fixedFirstChar; switch (settings.NamingRules.TupleElementNameCasing) { case TupleElementNameCase.PascalCase: reportDiagnostic = firstCharacterIsLower; - fixedName = char.ToUpper(tupleElementName[0]) + tupleElementName.Substring(1); + fixedFirstChar = char.ToUpper(tupleElementName[0]); break; default: reportDiagnostic = !firstCharacterIsLower; - fixedName = char.ToLower(tupleElementName[0]) + tupleElementName.Substring(1); + fixedFirstChar = char.ToLower(tupleElementName[0]); break; } @@ -136,6 +136,7 @@ private static void CheckName(SyntaxNodeAnalysisContext context, StyleCopSetting if (prepareCodeFix) { + var fixedName = fixedFirstChar + tupleElementName.Substring(1); diagnosticProperties.Add(ExpectedTupleElementNameKey, fixedName); }