You must have an attribute TupleElementNamesfor the method created by the compiler.
See this code :
public class C {
public (int a, int b) M() {
return (1, 2);
}
}
What compiles:
[return: TupleElementNames(new string[] {
"a",
"b"
})]
public ValueTuple<int, int> M()
{
return new ValueTuple<int, int>(1, 2);
}
You can get this attribute with this code:
Type t = typeof(C);
MethodInfo method = t.GetMethod(nameof(C.M));
var attr = method.ReturnParameter.GetCustomAttribute<TupleElementNamesAttribute>();
string[] names = attr.TransformNames;