コード例 #1
0
ファイル: TypeTests.cs プロジェクト: WillVan/clrmd
        public void IntegerObjectClrType()
        {
            using DataTarget dt      = TestTargets.Types.LoadFullDump();
            using ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
            ClrHeap heap = runtime.Heap;

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

            ClrObject obj = field.ReadObject();

            Assert.False(obj.IsNull);

            ClrType type = obj.Type;

            Assert.NotNull(type);

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

            var fds = obj.Type.Fields;

            int value = obj.ReadBoxed <int>();

            Assert.Equal(42, value);

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