public virtual ObjectValue[] GetObjectValueChildren (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, int firstItemIndex, int count, bool dereferenceProxy) { if (obj is EvaluationResult) return new ObjectValue[0]; if (IsArray (ctx, obj)) { ArrayElementGroup agroup = new ArrayElementGroup (ctx, CreateArrayAdaptor (ctx, obj)); return agroup.GetChildren (ctx.Options); } if (IsPrimitive (ctx, obj)) return new ObjectValue[0]; bool showRawView = false; // If there is a proxy, it has to show the members of the proxy object proxy = obj; if (dereferenceProxy) { proxy = GetProxyObject (ctx, obj); if (proxy != obj) { type = GetValueType (ctx, proxy); showRawView = true; } } TypeDisplayData tdata = GetTypeDisplayData (ctx, type); bool groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType (ctx, type)); List<ObjectValue> values = new List<ObjectValue> (); BindingFlags flattenFlag = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly; BindingFlags nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic; BindingFlags staticFlag = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static; BindingFlags access = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag; // Load all members to a list before creating the object values, // to avoid problems with objects being invalidated due to evaluations in the target, List<ValueReference> list = new List<ValueReference> (); list.AddRange (GetMembersSorted (ctx, objectSource, type, proxy, access)); var names = new ObjectValueNameTracker (ctx); object tdataType = type; foreach (ValueReference val in list) { try { object decType = val.DeclaringType; if (decType != null && decType != tdataType) { tdataType = decType; tdata = GetTypeDisplayData (ctx, decType); } DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name); if (state == DebuggerBrowsableState.Never) continue; if (state == DebuggerBrowsableState.RootHidden && dereferenceProxy) { object ob = val.Value; if (ob != null) { values.Clear (); values.AddRange (GetObjectValueChildren (ctx, val, ob, -1, -1)); showRawView = true; break; } } else { ObjectValue oval = val.CreateObjectValue (true); names.Disambiguate (val, oval); values.Add (oval); } } catch (Exception ex) { ctx.WriteDebuggerError (ex); values.Add (ObjectValue.CreateError (null, new ObjectPath (val.Name), GetDisplayTypeName (GetTypeName (ctx, val.Type)), ex.Message, val.Flags)); } } if (showRawView) { values.Add (RawViewSource.CreateRawView (ctx, objectSource, obj)); } else { if (IsArray (ctx, proxy)) { ICollectionAdaptor col = CreateArrayAdaptor (ctx, proxy); ArrayElementGroup agroup = new ArrayElementGroup (ctx, col); ObjectValue val = ObjectValue.CreateObject (null, new ObjectPath ("Raw View"), "", "", ObjectValueFlags.ReadOnly, values.ToArray ()); values = new List<ObjectValue> (); values.Add (val); values.AddRange (agroup.GetChildren (ctx.Options)); } else { if (ctx.Options.GroupStaticMembers && HasMembers (ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag)) { access = BindingFlags.Static | BindingFlags.Public | flattenFlag | nonNonPublicFlag; values.Add (FilteredMembersSource.CreateStaticsNode (ctx, objectSource, type, proxy, access)); } if (groupPrivateMembers && HasMembers (ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag)) values.Add (FilteredMembersSource.CreateNonPublicsNode (ctx, objectSource, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag)); if (!ctx.Options.FlattenHierarchy) { object baseType = GetBaseType (ctx, type, false); if (baseType != null) values.Insert (0, BaseTypeViewSource.CreateBaseTypeView (ctx, objectSource, baseType, proxy)); } } } return values.ToArray (); }
public virtual ObjectValue[] GetObjectValueChildren(EvaluationContext ctx, IObjectSource objectSource, object type, object obj, int firstItemIndex, int count, bool dereferenceProxy) { if (IsArray(ctx, obj)) { ArrayElementGroup agroup = new ArrayElementGroup(ctx, CreateArrayAdaptor(ctx, obj)); return(agroup.GetChildren(ctx.Options)); } if (IsPrimitive(ctx, obj)) { return(new ObjectValue[0]); } bool showRawView = false; // If there is a proxy, it has to show the members of the proxy object proxy = obj; if (dereferenceProxy) { proxy = GetProxyObject(ctx, obj); if (proxy != obj) { type = GetValueType(ctx, proxy); showRawView = true; } } TypeDisplayData tdata = GetTypeDisplayData(ctx, type); bool groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType(ctx, type)); List <ObjectValue> values = new List <ObjectValue> (); BindingFlags flattenFlag = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly; BindingFlags nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic; BindingFlags staticFlag = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static; BindingFlags access = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag; // Load all members to a list before creating the object values, // to avoid problems with objects being invalidated due to evaluations in the target, List <ValueReference> list = new List <ValueReference> (); list.AddRange(GetMembersSorted(ctx, objectSource, type, proxy, access)); object tdataType = type; foreach (ValueReference val in list) { try { object decType = val.DeclaringType; if (decType != null && decType != tdataType) { tdataType = decType; tdata = GetTypeDisplayData(ctx, decType); } DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name); if (state == DebuggerBrowsableState.Never) { continue; } if (state == DebuggerBrowsableState.RootHidden && dereferenceProxy) { object ob = val.Value; if (ob != null) { values.Clear(); values.AddRange(GetObjectValueChildren(ctx, val, ob, -1, -1)); showRawView = true; break; } } else { ObjectValue oval = val.CreateObjectValue(true); values.Add(oval); } } catch (Exception ex) { ctx.WriteDebuggerError(ex); values.Add(ObjectValue.CreateError(null, new ObjectPath(val.Name), GetDisplayTypeName(GetTypeName(ctx, val.Type)), ex.Message, val.Flags)); } } if (showRawView) { values.Add(RawViewSource.CreateRawView(ctx, objectSource, obj)); } else { if (IsArray(ctx, proxy)) { ICollectionAdaptor col = CreateArrayAdaptor(ctx, proxy); ArrayElementGroup agroup = new ArrayElementGroup(ctx, col); ObjectValue val = ObjectValue.CreateObject(null, new ObjectPath("Raw View"), "", "", ObjectValueFlags.ReadOnly, values.ToArray()); values = new List <ObjectValue> (); values.Add(val); values.AddRange(agroup.GetChildren(ctx.Options)); } else { if (ctx.Options.GroupStaticMembers && HasMembers(ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag)) { access = BindingFlags.Static | BindingFlags.Public | flattenFlag | nonNonPublicFlag; values.Add(FilteredMembersSource.CreateStaticsNode(ctx, objectSource, type, proxy, access)); } if (groupPrivateMembers && HasMembers(ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag)) { values.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, objectSource, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag)); } if (!ctx.Options.FlattenHierarchy) { object baseType = GetBaseType(ctx, type, false); if (baseType != null) { values.Insert(0, BaseTypeViewSource.CreateBaseTypeView(ctx, objectSource, baseType, proxy)); } } } } return(values.ToArray()); }