Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.56 KB

SA1414.md

File metadata and controls

64 lines (49 loc) · 1.56 KB

SA1414

TypeName SA1414TupleTypesInSignaturesShouldHaveElementNames
CheckId SA1414
Category Maintainability Rules

📝 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

A tuple type without element names is present in a member declaration.

Rule description

Tuple types appearing in member declarations should have explicitly named elements. 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:

public class ExampleClass
{
  public (int, int) ExampleMethod() // SA1414
  {
  }
}

The following code would not produce any violations:

public class ExampleClass
{
  public (int valueA, int valueB) ExampleMethod()
  {
  }
}

How to fix violations

To fix a violation of this rule, provide an element name for each tuple element.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.MaintainAbilityRules", "SA1414:TupleTypesInSignaturesShouldHaveElementNames", Justification = "Reviewed.")]
#pragma warning disable SA1414 // Tuple types appearing in member declarations should have explicitly named tuple elements
#pragma warning restore SA1414 // Tuple types appearing in member declarations should have explicitly named tuple elements