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