SA1316: Tuple element names should use correct casing
📝 This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic. 📝 This rule is only active for C# 7.0 and higher
Cause
Element names within a tuple type should have the correct casing.
Rule description
Tuple types with element names should use the configured casing for the element names (see Configuration.md for details). See the documentation on tuple types for information on how to work with tuples in C# 7.
For example, the following code would produce a violation of this rule (with default settings):
public class ExampleClass
{
public (int valueA, int valueB) ExampleMethod() // SA1316
{
}
}
The following code would not produce any violations:
public class ExampleClass
{
public (int ValueA, int ValueB) ExampleMethod()
{
}
}
Explicit element names in tuple expressions, such as (valueA: 1, valueB: 2), are checked in the same way. Element
names that are inferred from the expression, such as (valueA, valueB), are only checked when
includeInferredTupleElementNames is enabled (see Configuration.md).
How to fix violations
To fix a violation of this rule, correct the casing of the tuple element name.
How to suppress violations
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:TupleElementNamesShouldUseCorrectCasing", Justification = "Reviewed.")]
#pragma warning disable SA1316 // Tuple element names should use correct casing
#pragma warning restore SA1316 // Tuple element names should use correct casing