Skip to content
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

Invalidate variables cache in SetVariableAsync and in EvaluateExpressionAsync to have actual variables data #2169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -481,6 +481,10 @@ public async Task<string> SetVariableAsync(int variableContainerReferenceId, str
// This makes the returned string consistent with the strings normally displayed for variables in the debugger.
VariableDetails tempVariable = new(psVariable);
_logger.LogTrace($"Set variable '{name}' to: {tempVariable.ValueString ?? "<null>"}");

// Fetch stack frames and variables again to have actual data in the variables field.
// Without this, GetVariables and other methods that use the variables field will use old data.
await FetchStackFramesAndVariablesAsync(null).ConfigureAwait(false);
return tempVariable.ValueString;
}

Expand Down Expand Up @@ -508,6 +512,10 @@ public async Task<VariableDetails> EvaluateExpressionAsync(
command,
cancellationToken,
new PowerShellExecutionOptions { WriteOutputToHost = writeResultAsOutput, ThrowOnError = !writeResultAsOutput }).ConfigureAwait(false);

// Fetch stack frames and variables again to have actual data in the variables field.
// Without this, GetVariables and other methods that use the variables field will use old data.
await FetchStackFramesAndVariablesAsync(null).ConfigureAwait(false);
}
catch (Exception e)
{
Expand Down
Loading