Add type inference for Select-Object command (#7171)
Add type inference for Select-Object command Fixes #7170
This commit is contained in:
parent
dbaa1add3a
commit
3c079b9d42
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -64,3 +64,4 @@ TestsResults*.xml
|
|||
# Resharper settings
|
||||
PowerShell.sln.DotSettings.user
|
||||
*.msp
|
||||
StyleCop.Cache
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -352,6 +352,24 @@ Describe "Type inference Tests" -tags "CI" {
|
|||
}
|
||||
}
|
||||
|
||||
It "Infers typeof Select-Object when Member is ExpandProperty" {
|
||||
$res = [AstTypeInference]::InferTypeOf( { Get-ChildItem | Select-Object -ExpandProperty Directory }.Ast)
|
||||
$res.Count | Should -Be 1
|
||||
$res.Name | Should -Be "System.IO.DirectoryInfo"
|
||||
}
|
||||
|
||||
It "Infers typeof Select-Object when No projection is done" {
|
||||
$res = [AstTypeInference]::InferTypeOf( { "Hello" | Select-Object -First 1}.Ast)
|
||||
$res.Count | Should -Be 1
|
||||
$res.Name | Should -Be "System.String"
|
||||
}
|
||||
|
||||
It "Don't Infer typeof Select-Object when projection is done" {
|
||||
$res = [AstTypeInference]::InferTypeOf( { Get-ChildItem | Select-Object -Property Name}.Ast)
|
||||
$res.Count | Should -Be 0
|
||||
}
|
||||
|
||||
|
||||
It "Infers type from OutputTypeAttribute" {
|
||||
$res = [AstTypeInference]::InferTypeOf( { Get-Process -Id 2345 }.Ast)
|
||||
$gpsOutput = [Microsoft.PowerShell.Commands.GetProcessCommand].GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $false).Type
|
||||
|
|
Loading…
Reference in a new issue