I'm trying to get the real type of a nullable property from within an debug evaluator, but while for fields I get the right type arguments, for properties I don't:
Given code like this:
class Test { public static int? i2 = 15; public static int? i { get { return a; } set { a = value; }} }
And evaluator code like:
uint fetched; container.EnumFields( unchecked(enum_FIELD_KIND.FIELD_KIND_ALL), enum_FIELD_MODIFIERS.FIELD_MOD_ALL, null, NAME_MATCH.nmCaseInsensitive, out children); children.GetCount(out fetched); IDebugField[] fields = new IDebugField[fetched]; fetched = 0; children.Next((uint)fields.Length, fields, ref fetched); for (int i = 0; i < fetched; i++) { var fi = new FIELD_INFO[1]; fields[i].GetInfo(enum_FIELD_INFO_FIELDS.FIF_ALL, fi); if (!fi[0].bstrName.StartsWith("i")) continue; System.Diagnostics.Debug.WriteLine("Name: " + fi[0].bstrFullName); System.Diagnostics.Debug.WriteLine("Type: " + fi[0].bstrType); IDebugField ty; fields[i].GetType(out ty); IDebugGenericFieldInstance gen = ty as IDebugGenericFieldInstance; uint count = 0; gen.TypeArgumentCount(ref count); System.Diagnostics.Debug.WriteLine("Type GenArg Count: " + count); }
I'm getting this:
Name: i
Type: <unnamed>
Type GenArg Count: 0
Name: i2
Type: System.Nullable
Type GenArg Count: 1
So for the static field I am getting a proper generic type, for the property I don't. What am I doing wrong to get the type of the property?
Carlo Kok