示例#1
0
        public void Test()
        {
            object       x = "foo";
            HeapObject **h = Runtime.GetHeapObject(ref x);

            TestingAssertion.AssertHeapObject(ref x, h);

            string         s      = "foo";
            StringObject **strObj = Runtime.GetStringObject(ref s);

            TestingAssertion.AssertStringObject(ref s, strObj);

            int[]         arr    = { 1, 2, 3 };
            ArrayObject **arrObj = Runtime.GetArrayObject(ref arr);

            TestingAssertion.AssertArrayObject(ref arr, arrObj);

            s += " bar";
            Assert.That(s.Length, Is.EqualTo((**strObj).Length));
        }
示例#2
0
 internal static void AssertHeapObject <T>(ref T t, HeapObject **h) where T : class
 {
     Debug.Assert((**h).Header == Runtime.ReadObjHeader(ref t));
     Debug.Assert((**h).MethodTable == Runtime.ReadMethodTable(ref t));
 }
示例#3
0
        public static HeapObject **GetHeapObject <T>(ref T t) where T : class
        {
            HeapObject **h = (HeapObject **)Unsafe.AddressOf(ref t);

            return(h);
        }