@@ -193,18 +193,17 @@ public VariableDetails[] GetVariables(int variableReferenceId)
193193 }
194194
195195 /// <summary>
196- /// Evaluates an expression in the context of the stopped
197- /// debugger. For now, this just does simple evaluation of
198- /// a variable in the session. In the future it will execute
199- /// commands in the PowerShellSession.
196+ /// Evaluates a variable expression in the context of the stopped
197+ /// debugger. This method decomposes the variable expression to
198+ /// walk the cached variable data for the specified stack frame.
200199 /// </summary>
201- /// <param name="expressionString ">The expression string to execute .</param>
202- /// <param name="stackFrameId">The ID of the stack frame in which the expression should be executed .</param>
200+ /// <param name="variableExpression ">The variable expression string to evaluate .</param>
201+ /// <param name="stackFrameId">The ID of the stack frame in which the expression should be evaluated .</param>
203202 /// <returns>A VariableDetails object containing the result.</returns>
204- public VariableDetails EvaluateExpression ( string expressionString , int stackFrameId )
203+ public VariableDetails GetVariableFromExpression ( string variableExpression , int stackFrameId )
205204 {
206205 // Break up the variable path
207- string [ ] variablePathParts = expressionString . Split ( '.' ) ;
206+ string [ ] variablePathParts = variableExpression . Split ( '.' ) ;
208207
209208 VariableDetails resolvedVariable = null ;
210209 IEnumerable < VariableDetails > variableList = this . currentVariables ;
@@ -222,10 +221,10 @@ public VariableDetails EvaluateExpression(string expressionString, int stackFram
222221 v =>
223222 string . Equals (
224223 v . Name ,
225- expressionString ,
224+ variableExpression ,
226225 StringComparison . InvariantCultureIgnoreCase ) ) ;
227226
228- if ( resolvedVariable != null &&
227+ if ( resolvedVariable != null &&
229228 resolvedVariable . IsExpandable )
230229 {
231230 // Continue by searching in this variable's children
@@ -236,6 +235,29 @@ public VariableDetails EvaluateExpression(string expressionString, int stackFram
236235 return resolvedVariable ;
237236 }
238237
238+ /// <summary>
239+ /// Evaluates an expression in the context of the stopped
240+ /// debugger. This method will execute the specified expression
241+ /// PowerShellSession.
242+ /// </summary>
243+ /// <param name="expressionString">The expression string to execute.</param>
244+ /// <param name="stackFrameId">The ID of the stack frame in which the expression should be executed.</param>
245+ /// <returns>A VariableDetails object containing the result.</returns>
246+ public async Task < VariableDetails > EvaluateExpression ( string expressionString , int stackFrameId )
247+ {
248+ var results =
249+ await this . powerShellSession . ExecuteScriptString (
250+ expressionString ) ;
251+
252+ // Since this method should only be getting invoked in the debugger,
253+ // we can assume that Out-String will be getting used to format results
254+ // of command executions into string output.
255+
256+ return new VariableDetails (
257+ expressionString ,
258+ string . Join ( Environment . NewLine , results ) ) ;
259+ }
260+
239261 /// <summary>
240262 /// Gets the list of stack frames at the point where the
241263 /// debugger sf stopped.
0 commit comments