Cannot support multi-dimension arrays: GameStudio crash
See original GitHub issueRelease Type: GitHub
Version: v3.1
Platform(s): Windows 10 x64
Describe the bug Trying to use a script with a 3 dimension array as a public member crashes GameStudio. Might even crash on an array of size 2.
To Reproduce Steps to reproduce the behavior:
- Make a script with a public (custom class?) variable with 2+ dimensions
- Try and attach that script to an Entity in GameStudio
Log and callstacks
Exception: ArgumentException: Cannot support dimension [3] for type [GentrieveX.Scripts.WorldGen.ROOM_CELL_TYPE[,]]. Only supporting dimension of 1
at Xenko.Core.Reflection.ArrayDescriptor…ctor(ITypeDescriptorFactory factory, Type type, Boolean emitDefaultValues, IMemberNamingConvention namingConvention)
at Xenko.Core.Reflection.TypeDescriptorFactory.Create(Type type)
at Xenko.Core.Reflection.TypeDescriptorFactory.Find(Type type)
at Xenko.Core.Reflection.ObjectDescriptor.<PrepareMembers>b__45_4(FieldInfo fieldInfo)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator
1.MoveNext()
at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable
1 collection)
at Xenko.Core.Reflection.ObjectDescriptor.PrepareMembers()
at Xenko.Core.Reflection.ObjectDescriptor.Initialize(IComparer1 keyComparer) at Xenko.Core.Reflection.TypeDescriptorFactory.Find(Type type) at Xenko.Core.Reflection.ObjectDescriptor.<PrepareMembers>b__45_4(FieldInfo fieldInfo) at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List
1.InsertRange(Int32 index, IEnumerable1 collection) at Xenko.Core.Reflection.ObjectDescriptor.PrepareMembers() at Xenko.Core.Reflection.ObjectDescriptor.Initialize(IComparer
1 keyComparer)
at Xenko.Core.Reflection.TypeDescriptorFactory.Find(Type type)
at Xenko.Core.Reflection.ObjectDescriptor.<PrepareMembers>b__45_4(FieldInfo fieldInfo)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator
1.MoveNext()
at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable
1 collection)
at Xenko.Core.Reflection.ObjectDescriptor.PrepareMembers()
at Xenko.Core.Reflection.ObjectDescriptor.Initialize(IComparer`1 keyComparer)
at Xenko.Core.Reflection.TypeDescriptorFactory.Find(Type type)
at Xenko.Core.Reflection.DataVisitorBase.VisitCollection(IEnumerable collection, CollectionDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitCollection(IEnumerable collection, CollectionDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitObject(Object obj, ObjectDescriptor descriptor, Boolean visitMembers)
at Xenko.Core.Reflection.DataVisitorBase.Visit(Object obj, ITypeDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitObjectMember(Object container, ObjectDescriptor containerDescriptor, IMemberDescriptor member, Object value)
at Xenko.Core.Reflection.DataVisitorBase.VisitObject(Object obj, ObjectDescriptor descriptor, Boolean visitMembers)
at Xenko.Core.Assets.CollectionIdGenerator.VisitObject(Object obj, ObjectDescriptor descriptor, Boolean visitMembers)
at Xenko.Core.Reflection.DataVisitorBase.Visit(Object obj, ITypeDescriptor descriptor)
at Xenko.Core.Reflection.DataVisitorBase.VisitCollection(IEnumerable collection, CollectionDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitCollection(IEnumerable collection, CollectionDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitObject(Object obj, ObjectDescriptor descriptor, Boolean visitMembers)
at Xenko.Core.Reflection.DataVisitorBase.Visit(Object obj, ITypeDescriptor descriptor)
at Xenko.Core.Assets.CollectionIdGenerator.VisitObjectMember(Object container, ObjectDescriptor containerDescriptor, IMemberDescriptor mem
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
I don’t care for them to be supported, I just don’t want GameStudio to crash if it comes across one. Just skipping over that value in the inspector would work for me.
The callstack shows the specific type of array that caused the problem for me: [,]
I don’t think putting a try/catch around it and returning
null
is the best option. It is possible to check if it is a multi-dimension array by usingtype.GetArrayRank() != 1
. There are also quite a few spots that would cause aNullReferenceException
ifITypeDescriptorFactory.Find
returnednull
. Not sure why you didn’t get that problem though.