From 0da2ee71ff720c7c747005f2b2fba0b1c9880e7a Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Thu, 1 Jun 2017 13:20:25 -0600 Subject: [PATCH 1/3] Fix #821 missing note props in dbg variable viewer. --- .../Debugging/VariableDetails.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Debugging/VariableDetails.cs b/src/PowerShellEditorServices/Debugging/VariableDetails.cs index 5c3d34c74..3d11154ad 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}, script execution was attempted: {ex.Message}"); } return childVariables.ToArray(); From 3c924e486fec1a983c26c971003a625bcba646c7 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Thu, 1 Jun 2017 13:22:15 -0600 Subject: [PATCH 2/3] Tweak log message. --- src/PowerShellEditorServices/Debugging/VariableDetails.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Debugging/VariableDetails.cs b/src/PowerShellEditorServices/Debugging/VariableDetails.cs index 3d11154ad..a4a3014f7 100644 --- a/src/PowerShellEditorServices/Debugging/VariableDetails.cs +++ b/src/PowerShellEditorServices/Debugging/VariableDetails.cs @@ -343,7 +343,7 @@ private VariableDetails[] GetChildren(object obj) // 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}, script execution was attempted: {ex.Message}"); + Logger.Write(LogLevel.Warning, $"Failed to get properties of variable {this.Name}, value invocation was attempted: {ex.Message}"); } return childVariables.ToArray(); From 5518c90e49e0fb2e6e8431fa1f2caada69fdce25 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Thu, 1 Jun 2017 13:33:24 -0600 Subject: [PATCH 3/3] Process has 1 NoteProperty, bump expected count by 1. --- .../Debugging/DebugServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();