Skip to content

When the built-in $null was watched its value was incorrect #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,15 @@ public async Task<VariableDetails> EvaluateExpressionAsync(
return null;
}

// If we didn't write output,
// return a VariableDetails instance.
// If we didn't write output, return a VariableDetails instance.
return new VariableDetails(
expressionString,
string.Join(Environment.NewLine, results));
expressionString,
// If there's only one result, we want its raw value (especially if it's null). For
// a collection, since we're displaying these, we want to concatenante them.
// However, doing that for one result caused null to be turned into an empty string.
results.Count == 1
? results[0]
: string.Join(Environment.NewLine, results));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class DebugEvaluateHandler : IEvaluateHandler
private readonly IInternalPowerShellExecutionService _executionService;
private readonly DebugService _debugService;

// AKA Watch Variables
public DebugEvaluateHandler(
ILoggerFactory factory,
IPowerShellDebugContext debugContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ await debugService.SetCommandBreakpointsAsync(
AssertDebuggerStopped(testScript.FilePath, 11);

VariableDetails prompt = await debugService.EvaluateExpressionAsync("prompt", false, CancellationToken.None);
Assert.Equal("\"True > \"", prompt.ValueString);
Assert.Equal("True > ", prompt.ValueString);
}

[SkippableFact]
Expand Down