dotnet / dotnet/dotnet-api-docs

TupleElementNamesAttribute needs clarification

Open
#4,687 4 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime.CompilerServices Pri3
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

According to the documentation on TupleElementNamesAttribute at the bottom (https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Runtime.CompilerServices/TupleElementNamesAttribute.xml), the names are listed depth first notation, but from my testing it breath first. It is also unclear how tuples of size 8 and larger are handled.

For example:
```csharp
public IEnumerator<((int a11, int a12) a0, int b, (int c11, int c12) c0, int d, int e, int f, (int g11, int g12) g0, (int h1, int h2) h0, int i, int j, int k, int l, int m, int n, int o, int p, int q, int r, int s, int t, int u, int v)> abc()
{
throw new NotImplementedException();
}
```
```csharp
IList names = typeof(Program).GetMethod("abc").ReturnParameter.GetCustomAttribute().TransformNames;
Console.Out.WriteLine(string.Join(",", names.Select(s => s ?? "null")));
```
Outputs:
```
a0,b,c0,d,e,f,g0,h0,i,j,k,l,m,n,o,p,q,r,s,t,u,v,a11,a12,c11,c12,g11,g12,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,h1,h2,null,null,null,null,null,null,null,null,null
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.