private static IEnumerable <FieldInfo> GetFieldsFromHierarchy(Type type, BindingFlags bindingFlags) { while (type != null) { foreach (FieldInfo field in MemoryTracker.GetFields(type, bindingFlags)) { yield return(field); } type = type.BaseType; } }
private static IEnumerable <FieldInfo> GetFieldsFromHierarchy(Type type, BindingFlags bindingFlags) { while (type != null) { using (IEnumerator <FieldInfo> enumerator = MemoryTracker.GetFields(type, bindingFlags).GetEnumerator()) { if (enumerator.MoveNext()) { FieldInfo field = enumerator.Current; yield return(field); /*Error: Unable to find new state assignment for yield return*/; } } type = type.BaseType; } yield break; IL_00e0: /*Error near IL_00e1: Unexpected return in MoveNext()*/; }
private static void AccumulateStaticMembers(Type type, Dictionary <object, MemoryTracker.ReferenceData> references, HashSet <object> seen, Queue <object> toProcess) { foreach (MemoryTracker.ChildReference current in MemoryTracker.GetAllReferencedClassesFromClassOrStruct(null, MemoryTracker.GetFields(type, BindingFlags.Static), null, type.ToString() + ".")) { if (!current.child.GetType().IsClass) { throw new ApplicationException(); } MemoryTracker.ReferenceData referenceData = null; if (!references.TryGetValue(current.child, out referenceData)) { referenceData = new MemoryTracker.ReferenceData(); referenceData.path = current.path; referenceData.pathCost = 0; references[current.child] = referenceData; } if (!seen.Contains(current.child)) { seen.Add(current.child); toProcess.Enqueue(current.child); } } }