public void GetFieldFrom_WhenFieldFound_ReturnsField([Frozen] ClrHeap heap, ClrValueClass target, [Frozen] ClrType clrObjectType, ClrObject rawClrObject, ClrInstanceField clrObjValueField) { clrObjValueField.IsValueClass.Returns(true); clrObjValueField.Type.Returns(target.Type); clrObjValueField .GetAddress(rawClrObject.Address) .Returns(target.Address); // Act var structRefFieldTarget = rawClrObject.GetFieldFrom(clrObjValueField.Name); // Assert structRefFieldTarget.Equals(target).Should().BeTrue(); }
private static string DumpPropertyValue(ClrObject obj, string propertyName) { const string defaultContent = "?"; var field = obj.GetFieldFrom(propertyName); if (field.Type == null && field is ClrObject objectField && objectField.IsNull) { return("null"); } if (field.Type == null) { return(defaultContent); } if (field.Type.IsString) { return($"\"{new ClrObject(field.Address, field.Type).AsString()}\""); } else if (field.Type.IsArray) { return($"dumparray {field.Address:x16}"); } else if (field.Type.IsObjectReference) { return($"dumpobj {field.Address:x16}"); } else if (IsSimpleType(field.Type.Name) && TryGetSimpleValue(obj, field.Type, propertyName, out var simpleValuecontent)) { return(simpleValuecontent); } else if (field.Type.IsValueType) { return($"dumpvc {field.Type.MethodTable:x16} {field.Address:x16}"); } return(defaultContent); }