Add tuple item name reflection to contextual types
RicoSuter opened this issue · comments
Rico Suter commented
Max Koverdyaev commented
I have a technique to read a tuple type information in my project. Here's a link.
It may be not so relevant to the Namotion.Reflection library. Here's an algorithm description I used:
- For a given tuple understand there's named elements.
- Extract metadata of the tuple element names (all names go in a simple list of strings the similar way as for the NRT annotations).
- Make a pointer to the first name in the extracted names. This pointer will be needed to read nested tuples.
- Read the tuple type information
3.1. Get element types (needs to be flatten in case of a tuple of 8 or more elements)
3.2. Based on element count (flatten) extract a chunk of the element names associated with the current tuple.
3.3. Zip element types and names to get a type and name information about each tuple element.
3.4. Shift the name pointer to the next tuple element names chunk (+current tuple element count). - Recursively read the current tuple element types. If there's a nested tuple found move to the step 3.