Skip to content

Commit 5069baa

Browse files
committed
Regression: Most of FileInfo object properties is missing in debug view
Fixes #1649
1 parent 28bb5d2 commit 5069baa

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/Debugging/VariableDetails.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ private VariableDetails[] GetChildren(object obj, ILogger logger)
279279
childVariables.AddRange(
280280
psObject
281281
.Properties
282+
// Exclude Script properties. TODO: Marshal script properties back to runspace
283+
.Where(p => p.MemberType != PSMemberTypes.ScriptProperty)
282284
.Select(p => new VariableDetails(p)));
283285
}
284286
else
@@ -293,7 +295,11 @@ private VariableDetails[] GetChildren(object obj, ILogger logger)
293295
// Here we check the object's MemberType against the `Properties`
294296
// bit-mask to determine if this is a property. Hence the selection
295297
// will only include properties.
296-
.Where(p => (PSMemberTypes.Properties & p.MemberType) is not 0)
298+
.Where(p =>
299+
(PSMemberTypes.Properties & p.MemberType) is not 0 &&
300+
// Exclude Script properties. TODO: Marshal script properties back to runspace
301+
p.MemberType != PSMemberTypes.ScriptProperty
302+
)
297303
.Select(p => new VariableDetails(p)));
298304

299305
obj = psObject.BaseObject;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$fileInfoItem = Get-Item $PSScriptRoot/DebugFileInfoTest.ps1
2+
'Done'

test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class DebugServiceTests : IDisposable
2828
private readonly WorkspaceService workspace;
2929
private readonly ScriptFile debugScriptFile;
3030
private readonly ScriptFile variableScriptFile;
31+
private readonly ScriptFile variableFileInfoTestFile;
3132

3233
public DebugServiceTests()
3334
{
@@ -56,6 +57,7 @@ public DebugServiceTests()
5657
workspace = new WorkspaceService(NullLoggerFactory.Instance);
5758
debugScriptFile = GetDebugScript("DebugTest.ps1");
5859
variableScriptFile = GetDebugScript("VariableTest.ps1");
60+
variableFileInfoTestFile = GetDebugScript("VariableFileInfoTest.ps1");
5961
}
6062

6163
public void Dispose()
@@ -101,6 +103,8 @@ private Task ExecutePowerShellCommand(string command, params string[] args)
101103

102104
private Task ExecuteVariableScriptFile() => ExecutePowerShellCommand(variableScriptFile.FilePath);
103105

106+
private Task ExecuteVariableFileInfoTest() => ExecutePowerShellCommand(variableFileInfoTestFile.FilePath);
107+
104108
private void AssertDebuggerPaused()
105109
{
106110
var eventArgs = debuggerStoppedQueue.Take(new CancellationTokenSource(5000).Token);
@@ -528,6 +532,26 @@ await debugService.SetLineBreakpointsAsync(
528532
Assert.False(var.IsExpandable);
529533
}
530534

535+
// [Trait("Category", "DebugService")]
536+
// [Fact]
537+
// public async Task DebuggerFileInfoHasAllProperties()
538+
// {
539+
// await debugService.SetLineBreakpointsAsync(
540+
// variableFileInfoTestFile,
541+
// new[] { BreakpointDetails.Create(variableFileInfoTestFile.FilePath, 2) }).ConfigureAwait(true);
542+
543+
// Task _ = ExecuteVariableFileInfoTest();
544+
// AssertDebuggerStopped(variableFileInfoTestFile.FilePath);
545+
546+
// StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
547+
// VariableDetailsBase[] variables = debugService.GetVariables(stackFrames[0].AutoVariables.Id);
548+
549+
// var var = Array.Find(variables, v => v.Name == "$fileInfoItem");
550+
// Assert.NotNull(var);
551+
// Assert.Equal("\"Hello\"", var.ValueString);
552+
// Assert.False(var.IsExpandable);
553+
// }
554+
531555
[Trait("Category", "DebugService")]
532556
[Fact]
533557
public async Task DebuggerGetsVariables()

0 commit comments

Comments
 (0)