Title: Directly constructed .NET type instances lack properties that ones output by cmdlets have · Issue #4347 · PowerShell/PowerShell · GitHub
Open Graph Title: Directly constructed .NET type instances lack properties that ones output by cmdlets have · Issue #4347 · PowerShell/PowerShell
X Title: Directly constructed .NET type instances lack properties that ones output by cmdlets have · Issue #4347 · PowerShell/PowerShell
Description: Update: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members. #7501 From what I can tell, this discrepancy has always existed, so there may be...
Open Graph Description: Update: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members. #7501 From what I can tell, this discrep...
X Description: Update: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members. #7501 From what I can tell, this discrep...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4347
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Directly constructed .NET type instances lack properties that ones output by cmdlets have","articleBody":"_Update_: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members.\r\n\r\n * #7501\r\n \r\n---\r\n\r\nFrom what I can tell, this discrepancy has always existed, so there may be a good reason for it, but it deserves an explanation / documentation.\r\n\r\nSpecifically, 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`).\r\n\r\nThe 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.\r\n\r\nThe types used are just an example; the same discrepancy exists for other types, such as `[datetime]::now` vs. `Get-Date`.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n# Construct seemingly identical [System.IO.DirectoryInfo] instances\r\n([System.IO.DirectoryInfo] '/').psextended | Format-List\r\n'---'\r\n(Get-Item '/').psextended | Format-List\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\nPSPath : Microsoft.PowerShell.Core\\FileSystem::/\r\nPSParentPath : \r\nPSChildName : \r\nPSDrive : /\r\nPSProvider : Microsoft.PowerShell.Core\\FileSystem\r\nPSIsContainer : True\r\nMode : d-r---\r\nBaseName : /\r\nTarget : \r\nLinkType : \r\n\r\n---\r\n\r\nPSPath : Microsoft.PowerShell.Core\\FileSystem::/\r\nPSParentPath : \r\nPSChildName : \r\nPSDrive : /\r\nPSProvider : Microsoft.PowerShell.Core\\FileSystem\r\nPSIsContainer : True\r\nMode : d-r---\r\nBaseName : /\r\nTarget : \r\nLinkType : \r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nMode : d-r---\r\nBaseName : /\r\nTarget : \r\nLinkType : \r\n\r\n---\r\n\r\nPSPath : Microsoft.PowerShell.Core\\FileSystem::/\r\nPSParentPath : \r\nPSChildName : \r\nPSDrive : /\r\nPSProvider : Microsoft.PowerShell.Core\\FileSystem\r\nPSIsContainer : True\r\nMode : d-r---\r\nBaseName : /\r\nTarget : \r\nLinkType : \r\n```\r\n\r\nAs you can see, the `PS`-prefixed properties only exist on the instance output by `Get-Item`.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta.4 on macOS 10.12.5\r\nPowerShell Core v6.0.0-beta.4 on Ubuntu 16.04.2 LTS\r\nPowerShell Core v6.0.0-beta.4 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\nWindows PowerShell v5.1.15063.413 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-07-26T15:08:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":24},"url":"https://github.com/4347/PowerShell/issues/4347"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2282edfe-1ea2-68a1-307e-fd60eca325f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C062:38AC1:16EA24:1E15BB:6A5B179C |
| html-safe-nonce | 390b3761a137d6ef2196ceaa6dce31fad458db6c5e4ca60e7326e58c09cd9306 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDYyOjM4QUMxOjE2RUEyNDoxRTE1QkI6NkE1QjE3OUMiLCJ2aXNpdG9yX2lkIjoiNjA4NzI3OTYyOTE0MzMwNTI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d4fd4f2d26053941c24b2a3f938151f2a8a590b3e028a5c3e0a55ac47f457932 |
| hovercard-subject-tag | issue:245754913 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/4347/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7365f473846a65e564e9e95932aabf75dee4d123569741687cddf6bfb3b6ad8e/PowerShell/PowerShell/issues/4347 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7365f473846a65e564e9e95932aabf75dee4d123569741687cddf6bfb3b6ad8e/PowerShell/PowerShell/issues/4347 |
| og:image:alt | Update: See also this later proposal to provide the provider properties via class-backed CodeProperty members rather than per-instance NoteProperty members. #7501 From what I can tell, this discrep... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width