public void TestCreateSunshine() { var arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 8); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 7); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 6); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 5); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 4); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 3); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 2); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 1); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 0, 0); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 4, 4); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 4, 3); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 4, 2); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 4, 1); arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 4, 0); }
/// <summary> /// Marks the given object /// </summary> /// <param name="generation">The generation</param> /// <param name="objectReference">A reference to the object</param> private void MarkObject(CollectorGeneration generation, ObjectReference objectReference) { if (!objectReference.IsMarked) { objectReference.Mark(); if (objectReference.Type.IsArray) { //Mark ref elements var arrayType = (ArrayType)objectReference.Type; if (arrayType.ElementType.IsReference) { var arrayReference = new ArrayReference(objectReference); for (int i = 0; i < arrayReference.Length; i++) { var elementPtr = arrayReference.GetElement(i); this.MarkValue(generation, NativeHelpers.ReadLong(elementPtr), arrayType.ElementType); } } } else if (objectReference.Type.IsClass) { //Mark ref fields var classType = (ClassType)objectReference.Type; foreach (var field in classType.Metadata.Fields) { if (field.Type.IsReference) { var fieldValue = NativeHelpers.ReadLong(objectReference.DataPointer + field.LayoutOffset); this.MarkValue(generation, fieldValue, field.Type); } } } } }
public ArrayReference ReadArrayReference() { var reference = new ArrayReference(); reference.Size = Reader.ReadUInt32(); if (Magic.Is32Bit) reference.Offset = Reader.ReadUInt32(); else reference.Offset = Reader.ReadUInt64(); return reference; }
public void TestLengthWrong2() { var arr = new ArrayReference <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, 1, 8); }