Title: List of various Type completion flaws · Issue #16798 · PowerShell/PowerShell · GitHub
Open Graph Title: List of various Type completion flaws · Issue #16798 · PowerShell/PowerShell
X Title: List of various Type completion flaws · Issue #16798 · PowerShell/PowerShell
Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Open Graph Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
X Description: PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Opengraph URL: https://github.com/PowerShell/PowerShell
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"List of various Type completion flaws","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nI've looked into the type completion and have come up with this list of issues:\r\n\r\n1: It doesn't take conflicting `Using namespace` statements into consideration, for example:\r\n```\r\nusing namespace System.Threading\r\nusing namespace System.Timers\r\n[Timer\u003cTab>\r\n```\r\nwill suggest \"Timer\" but if you actually tried to use that you would get a runtime error due to the ambiguous type (it's either System.Threading.Timer or System.Timers.Timer). Ideally it would find the shortest unambiguous name, which in this case would be Threading.Timer and Timers.Timer due to the implicit System namespace.\r\n\r\n2: PowerShell types and Using namespace statements are only taken into consideration if they are included in the script text that is being completed. To demonstrate, you can add an Enum and a using statement to your $profile:\r\n```\r\nusing namespace System.Collections.Generic\r\nenum Whatever\r\n{\r\n value1 = 1\r\n}\r\n```\r\nFrom a new console, If you try to complete `Whatever` in the console you'll get no results. If you try to complete `List` it will suggest `System.Collections.Generic.List` instead of just `List`. \r\nIdeally PowerShell types defined in the script text as well as ones that have been loaded into the session should be included in the completions. For using statements, it should use the ones in the script text and if there aren't any, fall back to the ones loaded into the session.\r\n\r\n3: PowerShell types imported through using module aren't considered for completion. Fixing the previous issue would partially fix this, but maybe it's also worth parsing the specified module? The Symbol resolver code does this at parse time so maybe the completion code should as well?\r\n\r\n4: Namespaces aren't taken into consideration when completing input, their only use seems to be to trim types that are found. For example:\r\n```\r\nusing namespace System.Collections\r\n[Generic.List\u003cTab>\r\n#or\r\n[Generic.\u003cTab>\r\n```\r\n\r\nwon't complete to anything. You have to type the full name to get any completions.\r\n\r\n5: Quotes aren't handled properly in the namespace removal in the completion if used in `using namespace`\r\nFor example:\r\n```\r\nusing namespace \"System.Management\"\r\n[token\u003cTab>\r\n```\r\ncompletes to `[tomation.Language.Token]` instead of `[Automation.Language.Token]`\r\n### Expected behavior\r\n\r\n```console\r\nN/A\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nN/A\r\n```\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPS C:\\Users\\Martin> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.2.0-preview.10\r\nPSEdition Core\r\nGitCommitId 7.2.0-preview.10\r\nOS Microsoft Windows 10.0.19044\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/MartinGC94","@type":"Person","name":"MartinGC94"},"datePublished":"2022-01-24T23:20:25Z","url":"https://github.com/PowerShell/PowerShell/issues/16798"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:14b5630d-8cbe-98b0-6107-39d30806563f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B7BC:1EF65E:2B019:3F4D8:6AFDBB5B |
| html-safe-nonce | 458a51a1086fa404594ae6a69e2d5469c2169436c12fe1a0a9e353ea3b00a920 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0JDOjFFRjY1RToyQjAxOTozRjREODo2QUZEQkI1QiIsInZpc2l0b3JfaWQiOiI3NDM4MzcyMzk5MDkyNzEwMjM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b7c7a8d92ff6ce395a19630be721978831d47739f74bb01132421eb9fcdce4da |
| hovercard-subject-tag | repository:49609581 |
| 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/PowerShell/PowerShell/issues/16798 |
| twitter:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/49609581/aad0ad80-cdec-11ea-8248-a37bc0571bfd |
| og:image:alt | PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8309f07eb60a4237a657068c83d0bb57be4c7e02937f5e9933126f4bd596aac4 |
| turbo-cache-control | no-cache |
| 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 | 2f7154d847f1ddc5baa83b109a3e1d924605e2a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width