Title: AutomationNull Behaviour · Issue #9997 · PowerShell/PowerShell · GitHub
Open Graph Title: AutomationNull Behaviour · Issue #9997 · PowerShell/PowerShell
X Title: AutomationNull Behaviour · Issue #9997 · PowerShell/PowerShell
Description: See the comments in #9794 for the full extent of the existing discussion, starting with #9794 (comment) AutomationNull.Value is sometimes detectable and distinguishable from $null in certain cases, for example: using namespace System.Man...
Open Graph Description: See the comments in #9794 for the full extent of the existing discussion, starting with #9794 (comment) AutomationNull.Value is sometimes detectable and distinguishable from $null in certain cases,...
X Description: See the comments in #9794 for the full extent of the existing discussion, starting with #9794 (comment) AutomationNull.Value is sometimes detectable and distinguishable from $null in certain cases,...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9997
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AutomationNull Behaviour","articleBody":"See the comments in #9794 for the full extent of the existing discussion, starting with https://github.com/PowerShell/PowerShell/pull/9794#issuecomment-504796781\r\n\r\nAutomationNull.Value is sometimes detectable and distinguishable from $null in certain cases, for example:\r\n\r\n```powershell\r\nusing namespace System.Management.Automation.Internal\r\n\r\n$null -is [psobject] # false\r\n[AutomationNull]::Value -is [psobject] # true\r\n\r\n@($null).Count # 1\r\n@([AutomationNull]::Value).Count # 0\r\n```\r\n\r\n@SeeminglyScience mentioned a possible way we could have it be handled more closely like `[dbnull]` and `[nullstring]` are being handled as of #9794, without losing its current function in the pipeline internals, in https://github.com/PowerShell/PowerShell/pull/9794#issuecomment-505107426:\r\n\r\n\u003e Ideally if this were to be fixed it would just be removed from assignment, e.g. `$obj = [AutomationNull]::Value` would populate `$obj` with true `null`. The `-is` operator is one of the few things that never \"lie\" on occasion and I think it would be a detriment to change that.\r\n\u003e \r\n\u003e You can also make `[AutomationNull]::Value -is [AutomationNull]` work by:\r\n\u003e \r\n\u003e 1. Removing the `static` keyword from the class decl\r\n\u003e 2. Make it inherit `PSObject`\r\n\u003e 3. Change the singleton instance to `new AutomationNull()`\r\n\u003e \r\n\u003e That would allow `$autoNull -is [psobject]` to still work while enabling `$autoNull -is [AutomationNull]`. Though I think there are a few places in the compiler where it uses a pattern like `if (expr.ExpressionType == typeof(PSObject) \u0026\u0026 expr.Value == AutomationNull.Value)` so that might need to change.\r\n\r\n/cc @daxian-dbw @mklement0 \r\n\r\nI'm personally in favor of Patrick's solution, as it enables the very clear and concise `$item -is [AutomationNull]` with few downsides (the biggest downside being potential implementation complications, but in my opinion these are probably worth tackling). Interested to hear any further discussion on this! 💖 \r\n","author":{"url":"https://github.com/vexx32","@type":"Person","name":"vexx32"},"datePublished":"2019-06-24T18:00:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":44},"url":"https://github.com/9997/PowerShell/issues/9997"}
| 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:c44c00b5-37e7-f1a8-f304-28cdf49c7bd0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 866C:2D8562:3FC0E1:581302:6A5A4DCB |
| html-safe-nonce | c35ec5f23f5e7da0c86e73753d1e1e76bea8c1edf7cab821aa6e4d8d9fa9af2f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjZDOjJEODU2MjozRkMwRTE6NTgxMzAyOjZBNUE0RENCIiwidmlzaXRvcl9pZCI6IjUxMTIyNDAwODAzMjYxMTg4NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 58aaaf7b7e90e627b7ffa9bb26e734897016749dcea462ea937dbcc82236f728 |
| hovercard-subject-tag | issue:460022198 |
| 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/9997/issue_layout |
| twitter:image | https://opengraph.githubassets.com/125242f26b98dbe35068d73eba83b4b0867bf8a4253e6da1bbf616aa724f5e55/PowerShell/PowerShell/issues/9997 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/125242f26b98dbe35068d73eba83b4b0867bf8a4253e6da1bbf616aa724f5e55/PowerShell/PowerShell/issues/9997 |
| og:image:alt | See the comments in #9794 for the full extent of the existing discussion, starting with #9794 (comment) AutomationNull.Value is sometimes detectable and distinguishable from $null in certain cases,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vexx32 |
| hostname | github.com |
| expected-hostname | github.com |
| None | a793cd1fa898929111edad5857ee1f24ecf4bf7702525e67357cabc9df136fc3 |
| 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 | 311929384671aa49f385b6fcc680ae3933943203 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width