Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuple item name reflection to contextual types #81

Open
RicoSuter opened this issue Jun 1, 2021 · 1 comment
Open

Add tuple item name reflection to contextual types #81

RicoSuter opened this issue Jun 1, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@RicoSuter
Copy link
Owner

RicoSuter commented Jun 1, 2021

image

https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+ABATARgFgAobAZgAI8KBhCgbxIuasoApt8AGCgMQHt+SKtwoAhCAgCUFALJsOoiQC9hingEFhnHmJliArspkAHSRDAzGxFraoB2CmwBEEZ8OfBnUgNxMWAL4kAUA===

@RicoSuter RicoSuter added enhancement New feature or request help wanted Extra attention is needed labels Jun 1, 2021
@shadeglare
Copy link

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:

  1. For a given tuple understand there's named elements.
  2. Extract metadata of the tuple element names (all names go in a simple list of strings the similar way as for the NRT annotations).
  3. Make a pointer to the first name in the extracted names. This pointer will be needed to read nested tuples.
  4. 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).
  5. Recursively read the current tuple element types. If there's a nested tuple found move to the step 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants