-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: Extending Microsoft.CodeAnalysis.SyntaxTree (Fixes #549)
- Loading branch information
StartAutomating
authored and
StartAutomating
committed
Nov 5, 2023
1 parent
b5b0fbb
commit d6d13c8
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
.../System/Management/Automation/Language/VariableExpressionAst/GetVariableType.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
System.Management.Automation.Language.VariableExpressionAst.GetVariableType() | ||
----------------------------------------------------------------------------- | ||
|
||
|
||
|
||
|
||
### Synopsis | ||
Gets a Variable's Likely Type | ||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Description | ||
|
||
Determines the type of a variable. | ||
|
||
This looks for the closest assignment statement and uses this to determine what type the variable is likely to be. | ||
|
||
|
||
|
||
--- | ||
|
||
|
||
### Examples | ||
> EXAMPLE 1 | ||
```PowerShell | ||
{ | ||
[int]$x = 1 | ||
$y = 2 | ||
$x + $y | ||
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType() | ||
# Should -Be ([int]) | ||
``` | ||
> EXAMPLE 2 | ||
```PowerShell | ||
{ | ||
$x = Get-Process | ||
$x + $y | ||
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType() | ||
# Should -Be ([Diagnostics.Process]) | ||
``` | ||
> EXAMPLE 3 | ||
```PowerShell | ||
{ | ||
$x = [type].name | ||
$x | ||
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.GetVariableType() | ||
``` | ||
|
||
|
||
--- | ||
|
||
|
||
### Notes | ||
Subject to revision and improvement. While this covers many potential scenarios, it does not always | ||
|
||
|
||
|
||
--- |