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

Reflection_Engine: UnderlyingType returns wrong depth for arrays #703

Closed
epignatelli opened this issue Dec 5, 2018 · 1 comment · Fixed by #1124
Closed

Reflection_Engine: UnderlyingType returns wrong depth for arrays #703

epignatelli opened this issue Dec 5, 2018 · 1 comment · Fixed by #1124
Assignees
Labels
severity:critical No workaround exists. Essential to continue type:bug Error or unexpected behaviour
Milestone

Comments

@epignatelli
Copy link
Member

epignatelli commented Dec 5, 2018

This issue has been archived

Historic issue archive can be found here

@epignatelli epignatelli added this to the BHoM 2.1 MVP milestone Dec 5, 2018
@epignatelli epignatelli self-assigned this Dec 5, 2018
@adecler adecler removed this from the BHoM 2.1 MVP milestone Dec 21, 2018
@epignatelli epignatelli added this to the BHoM 2.2 MVP milestone Jan 4, 2019
@al-fisher al-fisher added severity:critical No workaround exists. Essential to continue type:bug Error or unexpected behaviour and removed bug_critical labels Mar 20, 2019
@epignatelli
Copy link
Member Author

epignatelli commented Jul 30, 2019

From historical comments:
This is related to BHoM/Grasshopper_UI#226

I don't know if it is intended, but if it is not, below the code to accomodate arrays: From this: https://github.com/BuroHappoldEngineering/BHoM_Engine/blob/f7650f27834436baed68ce0405e8f0402bc4771d/Reflection_Engine/Query/UnderlyingType.cs#L17-L27

To this:

    public static UnderlyingType UnderlyingType(this Type type)
    {
        int depth = 0;
        while ((type.GetGenericArguments().Count() == 1 || type.GetElementType() != null) && typeof(IEnumerable).IsAssignableFrom(type))
        {
            depth++;
            type = type.GetElementType() ?? type.GetGenericArguments().First();
        }

        return new UnderlyingType { Type = type, Depth = depth };
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity:critical No workaround exists. Essential to continue type:bug Error or unexpected behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants