Reflection support for Tuple and ValueTuple #44318
Labels
api-needs-work
API needs work before it is approved, it is NOT ready for implementation
area-System.Reflection
Milestone
Background and Motivation
When using
Tuple
andValueTuple
, metadata is hard to access:Tuple
, they are the property names. ForValueTuple
, they are field names. Also,Tuple
is an immutable reference type whileValueTuple
is a mutable value type which further complicates the usage patterns.Rest
property\field must be used, which is another Tuple, and thus the total count is not obvious and must be calculated.ValueTuple
must be obtained from reflection in a non-trivial manner by inspecting[TupleElementNames]
.At runtime, the
ITuple
interface is useful to abstract away theRest
property\field and provide a count, although it doesn't support the "TransformName". However, similar behavior is not available through reflection. See dotnet/csharplang#1906.Proposed API
System.Reflection.Extensions
assembly.TupleInfo
value type.API (in System.Reflection namespace):
InvalidOperationException
is thrown if the various metadata type (PropertyInfo
, etc) is not aTuple
orValueTuple
.Prototype at master...steveharter:ReflectionExt
The text was updated successfully, but these errors were encountered: