Beispiel #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));
        }
Beispiel #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));
 }
Beispiel #3
0
        public static HeapObject **GetHeapObject <T>(ref T t) where T : class
        {
            HeapObject **h = (HeapObject **)Unsafe.AddressOf(ref t);

            return(h);
        }