13
13
$y = 2
14
14
$x + $y
15
15
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType()
16
+ # Should -Be ([int])
16
17
. EXAMPLE
17
18
{
18
19
$x = Get-Process
19
20
$x + $y
20
21
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType()
22
+ # Should -Be ([Diagnostics.Process])
23
+ . EXAMPLE
24
+ {
25
+ $x = [type].name
26
+ $x
27
+ }.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.GetVariableType()
28
+
21
29
#>
22
30
if ($this.VariablePath.userPath -eq ' psBoundParmeters' ) {
23
31
return [Management.Automation.PSBoundParametersDictionary ]
@@ -59,7 +67,7 @@ $isMultiAssignment =$closestAssignment.Left -is [Management.Automation.Language.
59
67
60
68
# If the left side is not multiple assignment, but the right side is an array
61
69
if (-not $isMultiAssignment -and
62
- $closestAssignment.Right.Expression -is [Management.Automation.ArrayExpressionAst ]) {
70
+ $closestAssignment.Right.Expression -is [Management.Automation.Language. ArrayExpressionAst ]) {
63
71
# then the object is an array.
64
72
return [Object []]
65
73
}
@@ -83,7 +91,24 @@ if ($closestAssignment.Right.Expression -is [Management.Automation.Language.Conv
83
91
}
84
92
}
85
93
86
-
94
+ if ($closestAssignment.Right.Expression -is [Management.Automation.Language.MemberExpressionAst ]) {
95
+ $invokeMemberExpr = $closestAssignment.Right.Expression
96
+ $memberName = $invokeMemberExpr.Member.ToString ()
97
+ if ($invokeMemberExpr.Expression.TypeName ) {
98
+ $invokeType = $invokeMemberExpr.Expression.TypeName.GetReflectionType ()
99
+ if ($invokeType ) {
100
+ $potentialTypes = @ (
101
+ foreach ($invokeableMember in $invokeType.GetMember ($memberName , " Public, IgnoreCase,$ ( if ($invokeMemberExpr.Static ) { ' Static' } else { ' Instance' }) " )) {
102
+ if ($invokeableMember.PropertyType ) {
103
+ $invokeableMember.PropertyType
104
+ } elseif ($invokeableMember.ReturnType ) {
105
+ $invokeableMember.ReturnType
106
+ }
107
+ })
108
+ return $potentialTypes | Select-Object - Unique
109
+ }
110
+ }
111
+ }
87
112
88
113
89
114
# The right side could be a pipeline
0 commit comments