private List <string> computeRelativeRoots() { return(Roots.Where(r => r != ".").Select(r => { if (r.StartsWith(ClearcaseRoot)) { r = r.Substring(ClearcaseRoot.Length); } if (r.StartsWith("\\")) { r = r.Substring(1); } return r; }).ToList()); }
public void PrintDumpHeapStat(long minTotalSize = 1024) { var dumpHeapStat = DumpHeapStat(minTotalSize); var pinned = Roots.Where(r => r.IsPinned && r.Object.Type.Name == "System.Object[]"); var pinnedType = pinned.FirstOrDefault()?.Object.Type; var pinnedSize = pinned.Sum(p => (long)p.Object.Size); var pinnedCount = pinned.Count(); Console.WriteLine(" MT Count TotalSize Class Name"); foreach (var t in dumpHeapStat) { Console.WriteLine($"{t.type.MethodTable:X16} {t.objects.Count,8} {t.size,12} {t.type.Name}"); } var total = dumpHeapStat.Sum(d => d.objects.Count); Console.WriteLine($"Total {total} objects"); Console.WriteLine(); Console.WriteLine("Roots:"); Console.WriteLine($"{pinnedType.MethodTable:X16} {pinnedCount,8} {pinnedSize,12} {pinnedType.Name}"); }
/// <summary> /// Connects the threads. /// </summary> public void ConnectThreads() { foreach (var kvp in ThreadToExceptionMapping) { var thread = Threads[kvp.Key]; var exception = Objects[kvp.Value]; thread.CurrentException = exception; } foreach (var kvp in ThreadToRootMapping) { var thread = Threads[kvp.Key]; var roots = Roots.Where(r => kvp.Value.Contains(r.Key)).Select(x => x.Value).ToList(); foreach (var dumpObjectRoot in roots) { thread.AddRoot(dumpObjectRoot); dumpObjectRoot.AddThread(thread); } } foreach (var kvp in ThreadToObjectMapping) { var thread = Threads[kvp.Key]; foreach (var addr in kvp.Value) { if (Roots.TryGetValue(addr, out var o)) { thread.AddRoot(o); o.AddThread(thread); } else { ; } } } }
protected override void Generate(StringBuilder sourceCode) { var roots = Roots .Where(r => r.Types.Length >= 1) .ToList(); foreach (var root in roots) { Log(root.ToString()); } var namespaces = new List <string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.InteropServices", "Yamly", "Yamly.Proxy", "UnityEngine" }; foreach (var root in roots) { namespaces.Add(GetProxyNamespaceName(root.Root)); namespaces.AddRange(root.Namespaces); foreach (var attribute in root.ValidAttributes) { var dictionaryAttribute = attribute as AssetDictionaryAttribute; if (dictionaryAttribute == null) { continue; } var keyType = GetKeyType(root.Root, dictionaryAttribute); if (keyType != null && keyType.Namespace != null) { namespaces.Add(keyType.Namespace); } } } Include(namespaces.Distinct()); foreach (var root in roots) { Namespace(GetProxyNamespaceName(root.Root), () => { ListProxyGenericArguments.Clear(); DictionaryProxyGenericArguments.Clear(); NullableProxyGenericArguments.Clear(); foreach (var type in root.Types) { ProxyType(type); } foreach (var listTypeName in ListProxyGenericArguments) { ListType(listTypeName); } foreach (var pair in DictionaryProxyGenericArguments) { DictionaryType(pair.Key, pair.Value); } foreach (var valueTypeName in NullableProxyGenericArguments) { NullableType(valueTypeName); } }); } Namespace(StorageOutputNamespace, () => { ListProxyGenericArguments.Clear(); DictionaryProxyGenericArguments.Clear(); NullableProxyGenericArguments.Clear(); var definedStorageTypeNames = new HashSet <string>(); var definedCollectionTypeNames = new HashSet <string>(); foreach (var root in roots) { foreach (var attribute in root.ValidAttributes) { if (!CodeGenerationUtility.IsValidGroupName(attribute.Group)) { continue; } var storageTypeName = GetStorageTypeName(root.Root, attribute); if (definedStorageTypeNames.Contains(storageTypeName)) { continue; } StorageType(root, attribute); foreach (var listProxyGenericArgument in ListProxyGenericArguments) { var listTypeName = GetListTypeName(GetGluedTypeName(listProxyGenericArgument), true); if (definedCollectionTypeNames.Contains(listTypeName)) { continue; } definedCollectionTypeNames.Add(listTypeName); ListType(listProxyGenericArgument); } foreach (var dictionaryProxyGenericArguments in DictionaryProxyGenericArguments) { var keyTypeName = dictionaryProxyGenericArguments.Key; var valueTypeName = dictionaryProxyGenericArguments.Value; var dictionaryTypeName = GetDictionaryTypeName(GetGluedTypeName(keyTypeName), GetGluedTypeName(valueTypeName), true); if (definedCollectionTypeNames.Contains(dictionaryTypeName)) { continue; } definedCollectionTypeNames.Add(dictionaryTypeName); DictionaryType(keyTypeName, valueTypeName); } definedStorageTypeNames.Add(storageTypeName); } } }); ReferencedAssemblies = roots.SelectMany(r => r.Types) .Select(t => t.Assembly) .Distinct() .ToArray(); }