Пример #1
0
        public static void CompareMemorySnapshots(MemorySnapshot s, MemorySnapshot d, MemorySnapshot difSnapshot, CompareResult compareResult)
        {
            var sMemoryTypesLookup = s.memoryTypesLookup;
            var dMemoryTypesLookup = d.memoryTypesLookup;

            var sList = sMemoryTypesLookup.list;

            // Compare s with d
            for (int i = 0; i < sList.Count; i++)
            {
                ItemHolder <string, MemoryInstanceType> item = sList.items[i];
                MemoryInstanceType sMemoryInstanceType       = item.value;
                MemoryInstanceType dMemoryInstanceType;
                MemoryInstanceType difMemoryInstanceType = null;
                string             typeName = item.key;

                bool allSame = true;
                if (dMemoryTypesLookup.lookup.TryGetValue(typeName, out dMemoryInstanceType))
                {
                    // d Snapshot contains instance of item Type (could be all the same)
                    FastSortedHashSet <int, MemoryObject> sInstances = sMemoryInstanceType.instances;
                    HashSet <int> dInstancesLookup = dMemoryInstanceType.instances.lookup;

                    FastList <MemoryObject> sInstanceList = sInstances.list;

                    for (int j = 0; j < sInstanceList.Count; j++)
                    {
                        MemoryObject sMemoryObject = sInstanceList.items[j];

                        if (dInstancesLookup.Contains(sMemoryObject.instanceId))
                        {
                            continue;
                        }

                        // Add when doesn't contain
                        if (allSame)
                        {
                            allSame = false;
                            if (!difSnapshot.memoryTypesLookup.lookup.TryGetValue(typeName, out difMemoryInstanceType))
                            {
                                difMemoryInstanceType = new MemoryInstanceType(sMemoryInstanceType.type);
                                difSnapshot.memoryTypesLookup.Add(typeName, difMemoryInstanceType);
                                // DrawInfo info = GetObjectDrawInfo(difSnapshot.memoryLookup, typeName, true);
                            }
                        }

                        difMemoryInstanceType.instances.Add(sMemoryObject.instanceId, new MemoryObject(sMemoryObject, compareResult));
                    }
                }
                else
                {
                    // Add all instances
                    difMemoryInstanceType = new MemoryInstanceType(sMemoryInstanceType.type);
                    difSnapshot.memoryTypesLookup.Add(typeName, difMemoryInstanceType);
                    // DrawInfo info = GetObjectDrawInfo(difSnapshot.memoryLookup, typeName, true);
                    var sInstanceList = sMemoryInstanceType.instances.list;

                    for (int j = 0; j < sInstanceList.Count; j++)
                    {
                        difMemoryInstanceType.instances.Add(sInstanceList.items[j].instanceId, new MemoryObject(sInstanceList.items[j], compareResult));
                    }
                }
            }
        }
Пример #2
0
 public FastSortedHashSet(int capacity)
 {
     lookup = new HashSet <T>();
     list   = new FastList <T>(capacity);
 }
Пример #3
0
        static public void InitAssemblies(ref bool hasInitAssemblies, FastList <CustomAssembly> customAssemblies, Dictionary <NamespaceTypes, RuntimeInspector.DrawInfo> namespaceTypesLookup, Dictionary <string, FastList <Type> > typeNameLookup)
        {
            hasInitAssemblies = true;
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

            for (int i = 0; i < assemblies.Length; i++)
            {
                CustomAssembly customAssembly = new CustomAssembly();
                Assembly       assembly       = customAssembly.assembly = assemblies[i];
                customAssemblies.Add(customAssembly);

                string name = assembly.GetName().Name;
                customAssembly.name = name;

                bool isEditorAssembly = false;

                if (name.IndexOf("unity", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    customAssembly.type = AssemblyType.Unity;
                }
                else if (name.IndexOf("system", StringComparison.OrdinalIgnoreCase) != -1 || name == "mscorlib")
                {
                    customAssembly.type = AssemblyType.System;
                }
                else if (name.IndexOf("mono", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    customAssembly.type = AssemblyType.Mono;
                }
                else
                {
                    customAssembly.type = AssemblyType.Other;
                    if (name == "Assembly-CSharp-Editor" || name == "Assembly-CSharp-Editor-firstpass")
                    {
                        isEditorAssembly = true;
                    }
                }

                Type[] types;
                try
                {
                    types = assembly.GetTypes();
                }
                catch (ReflectionTypeLoadException e)
                {
                    types = e.Types.Where(x => x != null).ToArray();
                }

                for (int j = 0; j < types.Length; j++)
                {
                    Type type = types[j];

                    if (customAssembly.type == AssemblyType.Other && !isEditorAssembly)
                    {
                        RuntimeConsole.RegisterStaticType(type);
                    }

                    CustomType customType = new CustomType(customAssembly, type);
                    customAssembly.allTypes.Add(customType);

                    string namespaceString = type.Namespace;

                    if (namespaceString == null)
                    {
                        customAssembly.types.Add(customType);
                    }
                    else
                    {
                        NamespaceTypes namespaceTypes;
                        if (!customAssembly.namespaceLookup.lookup.TryGetValue(namespaceString, out namespaceTypes))
                        {
                            namespaceTypes = new NamespaceTypes(customAssembly, namespaceString);
                            customAssembly.namespaceLookup.Add(namespaceString, namespaceTypes);
                        }

                        namespaceTypes.types.Add(new CustomType(namespaceTypes, type));
                    }

                    string typeName = type.Name;

                    FastList <Type> typeList;
                    if (!typeNameLookup.TryGetValue(typeName, out typeList))
                    {
                        if (typeList == null)
                        {
                            typeList = new FastList <Type>();
                        }
                        typeNameLookup[typeName] = typeList;
                    }
                    typeList.Add(type);
                }
            }

            Array.Sort(customAssemblies.items, 0, customAssemblies.Count);

            for (int i = 0; i < customAssemblies.Count; i++)
            {
                customAssemblies.items[i].Sort();
            }

            RuntimeConsole.SortCommandsTable();
        }
Пример #4
0
 public FastSortedDictionary(int capacity)
 {
     lookup = new Dictionary <T, U>();
     list   = new FastList <ItemHolder <T, U> >(capacity);
 }