File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -137,9 +137,25 @@ class InvocationManager : IDisposable {
137
137
$value ))
138
138
}
139
139
140
- if ($usingstatement.SubExpression -is [IndexExpressionAst ]) {
141
- $idx = $usingstatement.SubExpression.Index.SafeGetValue ()
142
- $value = $value [$idx ]
140
+ if ($usingstatement.SubExpression -isnot [VariableExpressionAst ]) {
141
+ [Stack [Ast ]] $subexpressionStack = $usingstatement.SubExpression.FindAll ({
142
+ $args [0 ] -is [IndexExpressionAst ] -or
143
+ $args [0 ] -is [MemberExpressionAst ] },
144
+ $false )
145
+
146
+ while ($subexpressionStack.Count ) {
147
+ $subexpression = $subexpressionStack.Pop ()
148
+ if ($subexpression -is [IndexExpressionAst ]) {
149
+ $idx = $subexpression.Index.SafeGetValue ()
150
+ $value = $value [$idx ]
151
+ continue
152
+ }
153
+
154
+ if ($subexpression -is [MemberExpressionAst ]) {
155
+ $member = $subexpression.Member.SafeGetValue ()
156
+ $value = $value .$member
157
+ }
158
+ }
143
159
}
144
160
145
161
$usingParams.Add ($key , $value )
Original file line number Diff line number Diff line change 140
140
1 | Invoke-Parallel { $using :arr [-1 ] } | Should - BeExactly 10
141
141
1 | Invoke-Parallel { $using :hash [' FOO' ] } | Should - BeExactly ' bar'
142
142
}
143
+
144
+ It ' Allows member accessing on using: statemets' {
145
+ $hash = @ {
146
+ foo = @ {
147
+ bar = [pscustomobject ]@ { Index = 0 .. 10 }
148
+ }
149
+ }
150
+
151
+ 1 | Invoke-Parallel { $using :hash [' foo' ][' bar' ].Index[5 ] } | Should - BeExactly 5
152
+ }
143
153
}
144
154
}
You can’t perform that action at this time.
0 commit comments