lets say we have
class BaseClass
{
private int IntField = 10;
private string StringField = "base value"
}
class DerivedClass : BaseClass
{
private int IntField = 12;
private string StringField = "derived value"
}
if I just use IClrValue.ReadObjectField(fieldName) I always get values that were set for base class, because that fields first in the fields list. In order to resolve this issue I started to use IClrInstanceField.ReadObject(address, false) method. But unfortunately I can not use it always. it just returns something wrong and works well only if properties are duplicated.
Also I noticed that IClrInstanceField.ReadObject is a bit different from IClrValue.ReadObjectField although they do same things as it seems. The difference is in how they read values:
IClrInstanceField.ReadObject reads data using ContainingType
IClrValue.ReadObjectField reads data using IClrValue type.
in the end results are not same. Also, I managed to get correct values if I call IClrInstanceField.ReadObject with interior == false, when, as it seems, most natural to pass true
I also would propose to add overloads for IClrValue.ReadObjectField/ReadValueTypeField that use IClrInstanceField for field indication, not just fieldName.
lets say we have
if I just use
IClrValue.ReadObjectField(fieldName)I always get values that were set for base class, because that fields first in the fields list. In order to resolve this issue I started to useIClrInstanceField.ReadObject(address, false)method. But unfortunately I can not use it always. it just returns something wrong and works well only if properties are duplicated.Also I noticed that
IClrInstanceField.ReadObjectis a bit different fromIClrValue.ReadObjectFieldalthough they do same things as it seems. The difference is in how they read values:IClrInstanceField.ReadObjectreads data using ContainingTypeIClrValue.ReadObjectFieldreads data using IClrValue type.in the end results are not same. Also, I managed to get correct values if I call
IClrInstanceField.ReadObjectwith interior == false, when, as it seems, most natural to passtrueI also would propose to add overloads for
IClrValue.ReadObjectField/ReadValueTypeFieldthat use IClrInstanceField for field indication, not just fieldName.