applejag/Newtonsoft.Json-for-Unity

Question: Are array types not an issue for AOT support?

hhhmmmmmm opened this issue · 1 comments

If we have normal class T, is the array T[] not an issue for AOT support? Or typeof(T).MakeArrayType()? I ask because the AOTHelper doesn't include T[].

Haha I've actually not given thought about that. I need to test that to be certain.

However the AotHelper.EnsureList method does ensure List, which in turn ensures the T[] type to be generated. Technically a single statement such as the one found inside list.cs would do it to ensure the full array type to be operable:

        static readonly T[]  _emptyArray = new T[0];

But I'm also not too certain about this since arrays doesn't have constructors. At least the Array type in mscorlib uses an external invokation.

Don't quote me on this, I've not dug deeply enough to be certain, but arrays are so deeply integrated and managed by the .NET runtime that the only code they need AOT generated in an 100% AOT runtime environment would be the item type of the array itself, just to be able to figure out it's footprint and see if it's unmanaged or not.


Bottom line: It *should* be fine to use T[] arrays freely. If not then just use the AotHelper.EnsureList and it should work fine! (I will try test if it misbehaves too)