Title: Design Issues in Unix versions of Stop/Restart-Computer cmdlets · Issue #12482 · PowerShell/PowerShell · GitHub
Open Graph Title: Design Issues in Unix versions of Stop/Restart-Computer cmdlets · Issue #12482 · PowerShell/PowerShell
X Title: Design Issues in Unix versions of Stop/Restart-Computer cmdlets · Issue #12482 · PowerShell/PowerShell
Description: Code PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/ComputerUnix.cs Lines 1 to 159 in b7cb335 // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #if UNIX using System; using System.Dia...
Open Graph Description: Code PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/ComputerUnix.cs Lines 1 to 159 in b7cb335 // Copyright (c) Microsoft Corporation. // Licensed under the MIT License....
X Description: Code PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/ComputerUnix.cs Lines 1 to 159 in b7cb335 // Copyright (c) Microsoft Corporation. // Licensed under the MIT License....
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/12482
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Issues in Unix versions of Stop/Restart-Computer cmdlets","articleBody":"# Code\r\n\r\nhttps://github.com/PowerShell/PowerShell/blob/b7cb335f03fe2992d0cbd61699de9d9aafa1d7c1/src/Microsoft.PowerShell.Commands.Management/commands/management/ComputerUnix.cs#L1-L159\r\n\r\nI have several questions on these cmdlets... Below is a summarised list of issues with the current code.\r\n\r\n## 1. There is no null check for `_process.Dispose()` in the cmdlets' `Dispose()` methods\r\n\r\n... despite the fact that the test hook quite clearly prevents `_process` from ever being set if it's enabled. I'm almost as confused by this as I am by the fact that this doesn't make tests fail -- I suspect it's simply taking long enough to call its Dispose() method that the test it was executing inside of has already completed and the error goes unnoticed.\r\n\r\n## 2. The internal `RunCommand()` method has multiple design issues\r\n\r\nThe parameters it exposes are _never used_, and it uses hardcoded values instead.As a result, the different parameters provided by `Stop-Computer` and `Restart-Computer` are completely ignored, and thus the two commands do the exact same thing.\r\n\r\n## 3. The testing method.\r\n\r\nI acknowledge that it is rather difficult to test stopping/restarting a computer without causing interruptions in the test pipeline, but the current state of tests simply don't test _anything_ apart from basic parameter binding, since all other functionality in the cmdlet is completely skipped when the test hook is enabled.\r\n\r\nWe need a more robust way of testing these cmdlets; I think the lack of adequate tests is part of the reason the issues in these cmdlets went unnoticed.\r\n\r\n## 4. `IDisposable` is not implemented properly\r\n\r\nAccording to the documented [recommended pattern](https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose) there are two additional members that should be implemented as part of the IDisposable pattern, so that multiple calls to Dispose() effectively no-op after the first call.\r\n\r\n# Related Issues/PRs\r\n\r\n#5448 and #11151\r\n\r\n---\r\n\r\nThis code is still present in the current master branch of the repo and was included in 7.1-preview1, but it's still very much unfinished. Are there plans to finish it, at least to a minimum viable product?","author":{"url":"https://github.com/vexx32","@type":"Person","name":"vexx32"},"datePublished":"2020-04-24T19:34:41Z","url":"https://github.com/PowerShell/PowerShell/issues/12482"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1839ea44-1f5e-a001-a1d3-138d32de47c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C11C:1D853F:668E3:8AACB:6AFD48C5 |
| html-safe-nonce | caac7cf81f34a65214444853f8aa6f0b685d0a05a1847e06b951b489d5af357b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTFDOjFEODUzRjo2NjhFMzo4QUFDQjo2QUZENDhDNSIsInZpc2l0b3JfaWQiOiI5MTgzNDI0MDk2ODU4MDk3ODYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ca67cdcd891143884d4733e89b0ea5c97f41da6a01199fcf3045ce5fb26cb7eb |
| hovercard-subject-tag | issue:606536652 |
| 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/12482/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b710460d1484fc3cfe5ee73573d3c024bf74ecc4684a15812583c9ff40a494b0/PowerShell/PowerShell/issues/12482 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b710460d1484fc3cfe5ee73573d3c024bf74ecc4684a15812583c9ff40a494b0/PowerShell/PowerShell/issues/12482 |
| og:image:alt | Code PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/ComputerUnix.cs Lines 1 to 159 in b7cb335 // Copyright (c) Microsoft Corporation. // Licensed under the MIT License.... |
| 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 | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| 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 | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width