Find Array Type of Declared Variable

How is it possible to find the type of an array that is declared inline?
I can’t call Introspection.GetType() on anything other than Object so I can’t use it to pass the array in.
I can’t determine the type of the array by setting it to a variant and using Introspection.GetType() on the variant.
The debugger CAN determine the initial type of the array (so why can’t I?)
The running code knows to throw an exception if I try to add something of the wrong type.

Dim d() as dictionary d.MyArrayFunction

Function MyArrayFunction(objectArray() as Object) dim v as Variant = objectArray dim ti as Introspection.TypeInfo = Introspection.GetType(v) dim baseType as Introspection.TypeInfo = ti.BaseType //BaseType will be Nil break objectArray.Append new Dictionary //THIS LINE WILL WORK objectArray.Append new pair("123",123) //An exception of class IllegalCastException was not handled. The application must shut down. End Function

Why do you need to know? I ask because perhaps there is another way around this if your goal is serialization/deserialization.

Not doing serialization/deserialization.

Currently I’m doing something like this:

dim myObjects() as myClass db.sqlSelect(sqlStatement).CastTo(GetTypeInfo(myClass)).AppendTo(myObjects) return myObjects

I would like to simplify the second line into this:

db.sqlSelect(sqlStatement).CastInto(myObjects)

But in order to do this I need to be able to determine the type of the array.

(In case anyone is curious the function will convert each SQL Row into the proper XOJO object and append it to the array)

My brain is really fried at the moment but could you take the first value of the array and place it into an auto and get the type from that?

dim ti as xojo.Introspection.TypeInfo = xojo.Introspection.GetType(objectArray) dim ati as xojo.Introspection.TypeInfo = ti.ArrayElementType

Yeah, it seems that the new Introspection library supports getting the type of an array while the classic framework does not.

Now if only there was a way to convert a Xojo.Introspection.TypeInfo into the classic Introspection.TypeInfo it would be perfect…