Пример #1
0
        public void IntegerObjectClrType()
        {
            using DataTarget dt      = TestTargets.Types.LoadFullDump();
            using ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
            ClrHeap      heap   = runtime.Heap;
            ClrAppDomain domain = runtime.AppDomains.Single();

            ClrModule      module    = runtime.GetModule(ModuleName);
            ClrType        typesType = module.GetTypeByName("Types");
            ClrStaticField field     = typesType.GetStaticFieldByName("s_i");

            ClrObject obj = field.ReadObject(domain);

            Assert.False(obj.IsNull);

            ClrType type = obj.Type;

            Assert.NotNull(type);

            Assert.True(type.IsPrimitive);
            Assert.False(type.IsObjectReference);
            Assert.True(type.IsValueType);

            var fds = obj.Type.Fields;

            Assert.True(obj.IsBoxedValue);
            int value = obj.ReadBoxedValue <int>();

            Assert.Equal(42, value);

            Assert.Contains(obj.Address, heap.EnumerateObjects().Select(a => a.Address));
        }