Skip to content

use-tuple-syntax

C#stylefix: safedefault: offcsharp/stylecop

Reports ValueTuple<int, int> and ValueTuple.Create(a, b) where tuple syntax ((int, int) and (a, b)) can be used; not inside an expression tree. The fix is offered for types and ValueTuple.Create calls.

The tuple syntax is the form of the language, short and the one that supports element names. ValueTuple<...> is the type it compiles to, so writing it out is noise.

Reported
...
class Q : P, I {
public (int, int) Pair() => (1, 2);
...
public void Go(ValueTuple<int, int> t) {
...
var g = ValueTuple.Create(1, 2);
...
Debug.Assert(true, "why");
...
After the fix
...
class Q : P, I {
public (int, int) Pair() => (1, 2);
...
public void Go((int, int) t) {
...
var g = (1, 2);
...
Debug.Assert(true, "why");
...
csharp:
lint:
rules:
use-tuple-syntax: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line use-tuple-syntax in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
StyleCop SA1141 full