diff --git a/src/PowerShellEditorServices/Debugging/VariableDetails.cs b/src/PowerShellEditorServices/Debugging/VariableDetails.cs index 5c3d34c74..a4a3014f7 100644 --- a/src/PowerShellEditorServices/Debugging/VariableDetails.cs +++ b/src/PowerShellEditorServices/Debugging/VariableDetails.cs @@ -254,7 +254,7 @@ private static string InsertDimensionSize(string value, int dimensionSize) return result; } - private static VariableDetails[] GetChildren(object obj) + private VariableDetails[] GetChildren(object obj) { List childVariables = new List(); @@ -281,6 +281,13 @@ private static VariableDetails[] GetChildren(object obj) // If a PSObject other than a PSCustomObject, unwrap it. if (psObject != null) { + // First add the PSObject's ETS propeties + childVariables.AddRange( + psObject + .Properties + .Where(p => p.MemberType == PSMemberTypes.NoteProperty) + .Select(p => new VariableDetails(p))); + obj = psObject.BaseObject; } @@ -329,13 +336,14 @@ private static VariableDetails[] GetChildren(object obj) AddDotNetProperties(obj, childVariables); } } - catch (GetValueInvocationException) + catch (GetValueInvocationException ex) { // This exception occurs when accessing the value of a // variable causes a script to be executed. Right now // we aren't loading children on the pipeline thread so // this causes an exception to be raised. In this case, // just return an empty list of children. + Logger.Write(LogLevel.Warning, $"Failed to get properties of variable {this.Name}, value invocation was attempted: {ex.Message}"); } return childVariables.ToArray(); diff --git a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs index 9441f424f..18bf1f8c4 100644 --- a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs @@ -895,7 +895,7 @@ await this.debugService.SetLineBreakpoints( Assert.True(var.IsExpandable); var childVars = debugService.GetVariables(var.Id); - Assert.Equal(52, childVars.Length); + Assert.Equal(53, childVars.Length); // Abort execution of the script this.powerShellContext.AbortExecution();