Has anyone else run into this? Introspection on an array-typed field fails to yield the element type. Introspection on an array instance works. This fails in both 4.3 and 4.4.
using System;
using Microsoft.SPOT;
namespace BrokenArrays
{
public class TestClass
{
public int[] intArray;
public string[] stringArray;
}
public class Program
{
public static void Main()
{
var test = new TestClass();
var type = test.GetType();
// This always fails - can't determine the element type by instrospection on a field
var field = type.GetField("intArray");
if (field.FieldType.GetElementType()==null)
Debug.Print("failed to determine intArray element type");
else
Debug.Print(field.FieldType.GetElementType().FullName);
// Getting the type from an actual array instance succeeds
test.intArray = new int[5];
Debug.Print(test.intArray.GetType().GetElementType().FullName);
}
}
}