@@ -193,18 +193,17 @@ public VariableDetails[] GetVariables(int variableReferenceId)
193
193
}
194
194
195
195
/// <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.
200
199
/// </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>
203
202
/// <returns>A VariableDetails object containing the result.</returns>
204
- public VariableDetails EvaluateExpression ( string expressionString , int stackFrameId )
203
+ public VariableDetails GetVariableFromExpression ( string variableExpression , int stackFrameId )
205
204
{
206
205
// Break up the variable path
207
- string [ ] variablePathParts = expressionString . Split ( '.' ) ;
206
+ string [ ] variablePathParts = variableExpression . Split ( '.' ) ;
208
207
209
208
VariableDetails resolvedVariable = null ;
210
209
IEnumerable < VariableDetails > variableList = this . currentVariables ;
@@ -222,10 +221,10 @@ public VariableDetails EvaluateExpression(string expressionString, int stackFram
222
221
v =>
223
222
string . Equals (
224
223
v . Name ,
225
- expressionString ,
224
+ variableExpression ,
226
225
StringComparison . InvariantCultureIgnoreCase ) ) ;
227
226
228
- if ( resolvedVariable != null &&
227
+ if ( resolvedVariable != null &&
229
228
resolvedVariable . IsExpandable )
230
229
{
231
230
// Continue by searching in this variable's children
@@ -236,6 +235,29 @@ public VariableDetails EvaluateExpression(string expressionString, int stackFram
236
235
return resolvedVariable ;
237
236
}
238
237
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
+
239
261
/// <summary>
240
262
/// Gets the list of stack frames at the point where the
241
263
/// debugger sf stopped.
0 commit comments