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

Using inheritance and generics cause index out of range exception. #12

Closed
SKlimkov opened this issue Dec 2, 2017 · 2 comments
Closed
Assignees
Labels

Comments

@SKlimkov
Copy link

SKlimkov commented Dec 2, 2017

For example i have an abstract generic class A and inherited non-generic class B.

public abstract class A<TValue> 
{ 
    [OneLine]
    public List<TValue> List; 
}

public class B : A<ConreteValue> 
{ 
}

This case cause Index out of range exception for SerializedPropertyExtension in 104 line. You will replace

type = type.GetGenericArguments()[0];

for

if (type.GetGenericArguments().Length == 0)
{                            
    var baseType = type.BaseType;
    type = baseType.GetGenericArguments()[0];
}
else
{
    type = type.GetGenericArguments()[0];
} 

for fix it.

@slavniyteo
Copy link
Owner

Thank you for this bug report. I edited issue text to make it more readable.

I will fix it soon.

@slavniyteo slavniyteo self-assigned this Dec 3, 2017
@slavniyteo slavniyteo added the bug label Dec 3, 2017
@slavniyteo
Copy link
Owner

This is more complex bug based on wrong BindingFlags passed into type.GetField.

Your solution with type.BaseType works only in this custom case. But If your have the same classes A and B but whithout any generic behaviour, but is still here:

public abstract class A
{ 
    [OneLine]
    public List<Vector2> List; 
}

public class B : A
{ 
}

Now, in e3f3297 it is fully fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants