Fix ListUserData erroring on type retrieval

This commit is contained in:
Deukhoofd 2019-01-26 14:08:18 +01:00
parent ee36060dd6
commit ce030c484f
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 18 additions and 6 deletions

View File

@ -20,14 +20,28 @@ namespace Upsilon.BaseTypes.UserData
{ {
List = list; List = list;
var type = list.GetType(); var type = list.GetType();
System.Type elementType;
if (type.IsArray) if (type.IsArray)
{ {
TypeName = BoundTypeHandler.GetTypeName(type.GetElementType()); elementType = type.GetElementType();
TypeName = BoundTypeHandler.GetTypeName(elementType);
} }
else else
{ {
var generic = type.GetGenericArguments()[0]; elementType = type.GetGenericArguments()[0];
TypeName = BoundTypeHandler.GetTypeName(generic); TypeName = BoundTypeHandler.GetTypeName(elementType);
}
if (TypeName == null)
{
Type = new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new UndefinedUserDataTypeContainer(elementType)}
.ToImmutableArray());
}
else
{
Type = new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new TypeContainer(TypeName)}
.ToImmutableArray());
} }
} }
@ -88,9 +102,7 @@ namespace Upsilon.BaseTypes.UserData
} }
} }
public override TypeContainer Type => public override TypeContainer Type { get; }
new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new TypeContainer(TypeName)}
.ToImmutableArray());
public override object ToCSharpObject() public override object ToCSharpObject()
{ {
return List; return List;