Skip to content

Fix DebuggerSetsVariablesWithConversion test which indicates bug #1661

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

Closed
andyleejordan opened this issue Jan 12, 2022 · 0 comments · Fixed by #1664
Closed

Fix DebuggerSetsVariablesWithConversion test which indicates bug #1661

andyleejordan opened this issue Jan 12, 2022 · 0 comments · Fixed by #1664
Assignees
Labels
Milestone

Comments

@andyleejordan
Copy link
Member

I confirmed this is a real bug when reproducing manually. Setting variables with the preview's debugger can fail if they need to be converted. Left a note actually where it throws the exception.

[Fact(Skip = "Variable conversion is broken")]
public async Task DebuggerSetsVariablesWithConversion()
{
await debugService.SetLineBreakpointsAsync(
variableScriptFile,
new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 14) }).ConfigureAwait(true);
// Execute the script and wait for the breakpoint to be hit
Task _ = ExecuteVariableScriptFile();
AssertDebuggerStopped(variableScriptFile.FilePath);
VariableScope[] scopes = debugService.GetVariableScopes(0);
VariableDetailsBase[] variables = GetVariables(VariableContainerDetails.LocalScopeName);
// Test set of a local string variable (not strongly typed but force conversion)
const string newStrValue = "False";
const string newStrExpr = "$false";
VariableScope localScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.LocalScopeName);
string setStrValue = await debugService.SetVariableAsync(localScope.Id, "$strVar2", newStrExpr).ConfigureAwait(true);
Assert.Equal(newStrValue, setStrValue);
// Test set of script scope bool variable (strongly typed)
VariableScope scriptScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.ScriptScopeName);
const string newBoolValue = "$true";
const string newBoolExpr = "1";
string setBoolValue = await debugService.SetVariableAsync(scriptScope.Id, "$scriptBool", newBoolExpr).ConfigureAwait(true);
Assert.Equal(newBoolValue, setBoolValue);
// Test set of global scope ActionPreference variable (strongly typed)
VariableScope globalScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.GlobalScopeName);
const string newGlobalValue = "Continue";
const string newGlobalExpr = "'Continue'";
string setGlobalValue = await debugService.SetVariableAsync(globalScope.Id, "$VerbosePreference", newGlobalExpr).ConfigureAwait(true);
Assert.Equal(newGlobalValue, setGlobalValue);
// The above just tests that the debug service returns the correct new value string.
// Let's step the debugger and make sure the values got set to the new values.
await Task.Run(() => debugService.StepOver()).ConfigureAwait(true);
AssertDebuggerStopped(variableScriptFile.FilePath);
// Test set of a local string variable (not strongly typed but force conversion)
variables = GetVariables(VariableContainerDetails.LocalScopeName);
var strVar = Array.Find(variables, v => v.Name == "$strVar2");
Assert.Equal(newStrValue, strVar.ValueString);
scopes = debugService.GetVariableScopes(0);
// Test set of script scope bool variable (strongly typed)
variables = GetVariables(VariableContainerDetails.ScriptScopeName);
var boolVar = Array.Find(variables, v => v.Name == "$scriptBool");
Assert.Equal(newBoolValue, boolVar.ValueString);
// Test set of global scope ActionPreference variable (strongly typed)
variables = GetVariables(VariableContainerDetails.GlobalScopeName);
var globalVar = Array.Find(variables, v => v.Name == "$VerbosePreference");
Assert.Equal(newGlobalValue, globalVar.ValueString);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant