Exemplo n.º 1
0
            public void Initialize(ConnectionsControl owner, PackedMemorySnapshot snapshot, int arrayIndex)
            {
                m_Owner         = owner;
                m_ManagedObject = new RichManagedObject(snapshot, arrayIndex);

                displayName = m_ManagedObject.type.name;
                address     = m_ManagedObject.address;
                m_Value     = m_ManagedObject.nativeObject.isValid ? m_ManagedObject.nativeObject.name : "";
                m_Tooltip   = PackedManagedTypeUtility.GetInheritanceAsString(snapshot, m_ManagedObject.type.packed.managedTypesArrayIndex);
            }
Exemplo n.º 2
0
        protected override void OnInitialize()
        {
            m_Pointer = m_MemoryReader.ReadPointer(address);

            // If it's a pointer, read the actual object type from the object in memory
            // and do not rely on the field type. The reason for this is that the field type
            // could be just the base-type or an interface, but the want to display the actual object type instead-
            var type = m_Snapshot.managedTypes[field.managedTypesArrayIndex];

            if (type.isPointer && m_Pointer != 0)
            {
                var i = m_Snapshot.FindManagedObjectTypeOfAddress(m_Pointer);
                if (i != -1)
                {
                    type = m_Snapshot.managedTypes[i];
                }
            }

            base.type    = type;
            displayName  = field.name;
            displayType  = type.name;
            displayValue = m_MemoryReader.ReadFieldValueAsString(address, type);
            isExpandable = false;// m_pointer > 0 && PackedManageTypeUtility.HasTypeOrBaseAnyInstanceField(m_snapshot, type);
            enabled      = m_Pointer > 0;
            icon         = HeEditorStyles.GetTypeImage(m_Snapshot, type);

            if (field.isStatic)
            {
                displayType = "static " + displayType;

                //PackedManagedType firstType;
                //if (PackedManageTypeUtility.HasTypeOrBaseAnyStaticField(m_snapshot, type, out firstType))
                //    allowExpand = m_pointer > 0 && firstType.managedTypeArrayIndex != type.managedTypeArrayIndex;
            }
            //else
            //{
            //    // HashString has a HashString static field (HashString.Empty)
            //    // The following line makes sure that we cannot infinitely expand the same type
            //    PackedManagedType firstType;
            //    if (PackedManageTypeUtility.HasTypeOrBaseAnyInstanceField(m_snapshot, type, out firstType))
            //        allowExpand = m_pointer > 0 && firstType.managedTypeArrayIndex != type.managedTypeArrayIndex;
            //}

            // HashString has a HashString static field (HashString.Empty)
            // The following line makes sure that we cannot infinitely expand the same type
            PackedManagedType firstType;

            if (PackedManagedTypeUtility.HasTypeOrBaseAnyInstanceField(m_Snapshot, type, out firstType))
            {
                isExpandable = m_Pointer > 0 && firstType.managedTypesArrayIndex != type.managedTypesArrayIndex;
            }
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            if (m_IsInitialized)
            {
                return;
            }
            m_IsInitialized = true;

            OnInitialize();

            var text = string.Format("{0} {1} = {2}\n\n{3}",
                                     displayType,
                                     displayName,
                                     displayValue,
                                     PackedManagedTypeUtility.GetInheritanceAsString(m_Snapshot, type.managedTypesArrayIndex));

            this.tooltip = text.Trim();
        }
Exemplo n.º 4
0
        protected override void OnInitialize()
        {
            type         = m_Snapshot.managedTypes[field.managedTypesArrayIndex];
            displayName  = field.name;
            displayType  = type.name;
            displayValue = m_MemoryReader.ReadFieldValueAsString(address, type);
            isExpandable = false;

            if (field.isStatic)
            {
                displayType = "static " + displayType;

                //PackedManagedType firstType;
                //if (PackedManageTypeUtility.HasTypeOrBaseAnyStaticField(m_snapshot, m_Type, out firstType))
                //    allowExpand = firstType.managedTypeArrayIndex != m_Type.managedTypeArrayIndex;
            }
            //else
            //{
            //    // HashString has a HashString static field (HashString.Empty)
            //    // The following line makes sure that we cannot infinitely expand the same type
            //    PackedManagedType firstType;
            //    if (PackedManageTypeUtility.HasTypeOrBaseAnyInstanceField(m_snapshot, m_Type, out firstType))
            //        allowExpand = firstType.managedTypeArrayIndex != m_Type.managedTypeArrayIndex;
            //}

            // HashString has a HashString static field (HashString.Empty)
            // The following line makes sure that we cannot infinitely expand the same type
            PackedManagedType firstType;

            if (PackedManagedTypeUtility.HasTypeOrBaseAnyInstanceField(m_Snapshot, type, out firstType))
            {
                isExpandable = firstType.managedTypesArrayIndex != type.managedTypesArrayIndex;
            }

            icon = HeEditorStyles.GetTypeImage(m_Snapshot, type);
        }
Exemplo n.º 5
0
        void AddType(PropertyGridItem.BuildChildrenArgs args)
        {
            var target      = args.parent;
            var type        = args.type;
            var address     = args.address;
            var reader      = args.memoryReader;
            var addStatic   = reader is StaticMemoryReader;
            var addInstance = !addStatic;

            if (target.depth > 64)
            {
                Debug.LogFormat("recursive reference found? type: {0}", type.name);
                return;
            }

            // Add the base class, if any, to the tree.
            if (type.isDerivedReferenceType && !type.isArray)
            {
                var baseType       = m_Snapshot.managedTypes[type.baseOrElementTypeIndex];
                var isSystemObject = baseType.managedTypesArrayIndex == m_Snapshot.coreTypes.systemObject;
                if (!isSystemObject && PackedManagedTypeUtility.HasTypeOrBaseAnyField(m_Snapshot, baseType, !addStatic, addStatic))
                {
                    var item = new BaseClassPropertyGridItem(this, m_Snapshot, address, reader)
                    {
                        depth = target.depth + 1,
                        type  = baseType
                    };
                    item.Initialize();

                    target.AddChild(item);
                }
            }

            // Array
            if (type.isArray)
            {
                // Normally the baseOrElementTypeIndex of an array represents the element type.
                // If inspecting static generic fields though, there is no element type available for '_EmptyArray'.
                // class ArrayList<T>
                // {
                //   static readonly T[] _EmptyArray = new T[0];
                // }
                if (type.baseOrElementTypeIndex == -1)
                {
                    return;
                }

                var pointer = address;
                var item    = new ArrayPropertyGridItem(this, m_Snapshot, pointer, reader)
                {
                    depth       = target.depth + 1,
                    type        = type,
                    displayName = type.name,
                };
                item.Initialize();

                target.AddChild(item);
                return;
            }



            for (var n = 0; n < type.fields.Length; ++n)
            {
                if (type.fields[n].isStatic && !addStatic)
                {
                    continue;
                }

                if (!type.fields[n].isStatic && !addInstance)
                {
                    continue;
                }

                var fieldType = m_Snapshot.managedTypes[type.fields[n].managedTypesArrayIndex];

                // Array
                if (fieldType.isArray)
                {
                    if (fieldType.baseOrElementTypeIndex == -1)
                    {
                        continue;
                    }

                    var pointer = reader.ReadPointer(address + (ulong)type.fields[n].offset);
                    var item    = new ArrayPropertyGridItem(this, m_Snapshot, pointer, new MemoryReader(m_Snapshot))
                    {
                        depth       = target.depth + 1,
                        type        = fieldType,
                        displayName = type.fields[n].name
                    };
                    item.Initialize();

                    target.AddChild(item);
                    continue;
                }

                // Primitive types and types derived from System.Enum
                if (fieldType.isValueType && (fieldType.isPrimitive || m_Snapshot.IsEnum(fieldType)))
                {
                    var item = new PrimitiveTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader)
                    {
                        depth = target.depth + 1,
                        field = type.fields[n]
                    };
                    item.Initialize();

                    target.AddChild(item);
                    continue;
                }

                // Value types
                if (fieldType.isValueType)
                {
                    var item = new ValueTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader)
                    {
                        depth = target.depth + 1,
                        field = type.fields[n]
                    };
                    item.Initialize();

                    target.AddChild(item);
                    continue;
                }

                // Reference types
                //if (fieldType.isPointer)
                {
                    var item = new ReferenceTypePropertyGridItem(this, m_Snapshot, address + (ulong)type.fields[n].offset, reader)
                    {
                        depth = target.depth + 1,
                        field = type.fields[n]
                    };
                    item.Initialize();

                    target.AddChild(item);
                    continue;
                }
            }
        }