-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Update: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members.
From what I can tell, this discrepancy has always existed, so there may be a good reason for it, but it deserves an explanation / documentation.
Specifically, where do the extra properties come from? They appear not to be part of the ETS type data as returned by Get-TypeData System.IO.DirectoryInfo (and there's also none for the parent type, Get-TypeData System.IO.FileSystemInfo).
The absence of the .PSPath property from the directly constructed [System.IO.DirectoryInfo] and [System.IO.FileInfo] instances is especially problematic, because pipeline-binding to -LiteralPath parameters is based on it.
The types used are just an example; the same discrepancy exists for other types, such as [datetime]::now vs. Get-Date.
Steps to reproduce
# Construct seemingly identical [System.IO.DirectoryInfo] instances
([System.IO.DirectoryInfo] '/').psextended | Format-List
'---'
(Get-Item '/').psextended | Format-ListExpected behavior
PSPath : Microsoft.PowerShell.Core\FileSystem::/
PSParentPath :
PSChildName :
PSDrive : /
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Mode : d-r---
BaseName : /
Target :
LinkType :
---
PSPath : Microsoft.PowerShell.Core\FileSystem::/
PSParentPath :
PSChildName :
PSDrive : /
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Mode : d-r---
BaseName : /
Target :
LinkType :
Actual behavior
Mode : d-r---
BaseName : /
Target :
LinkType :
---
PSPath : Microsoft.PowerShell.Core\FileSystem::/
PSParentPath :
PSChildName :
PSDrive : /
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Mode : d-r---
BaseName : /
Target :
LinkType :
As you can see, the PS-prefixed properties only exist on the instance output by Get-Item.
Environment data
PowerShell Core v6.0.0-beta.4 on macOS 10.12.5
PowerShell Core v6.0.0-beta.4 on Ubuntu 16.04.2 LTS
PowerShell Core v6.0.0-beta.4 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.413 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)