-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Description
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.
PowerShellEditorServices/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs
Lines 616 to 672 in 20a3516
[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); | |
} |