Skip to content

Commit 78930cc

Browse files
authored
Fix child expand (#223)
* Return no children if cannot expand * Only ask for public instance members * Fix whitespace formatting
1 parent 9619e5d commit 78930cc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Microsoft.PowerShell.ConsoleGuiTools/ShowObjectView.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ private static bool IsBasicType(object value)
205205

206206
public IEnumerable<object> GetChildren(object forObject)
207207
{
208+
if (forObject == null || !this.CanExpand(forObject))
209+
{
210+
return Enumerable.Empty<object>();
211+
}
212+
208213
if (forObject is CachedMemberResult p)
209214
{
210215
if (p.IsCollection)
@@ -222,7 +227,7 @@ public IEnumerable<object> GetChildren(object forObject)
222227

223228
List<object> children = new List<object>();
224229

225-
foreach (var member in forObject.GetType().GetMembers().OrderBy(m => m.Name))
230+
foreach (var member in forObject.GetType().GetMembers(BindingFlags.Instance | BindingFlags.Public).OrderBy(m => m.Name))
226231
{
227232
if (member is PropertyInfo prop)
228233
{

0 commit comments

Comments
 (0)