Skip to content

Fileds duplication case #1370

@shvez

Description

@shvez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions