Title: DE0006: Non-generic collections shouldn't be used (especially in Pester tests) · Issue #10315 · PowerShell/PowerShell · GitHub
Open Graph Title: DE0006: Non-generic collections shouldn't be used (especially in Pester tests) · Issue #10315 · PowerShell/PowerShell
X Title: DE0006: Non-generic collections shouldn't be used (especially in Pester tests) · Issue #10315 · PowerShell/PowerShell
Description: As per .NET Platform compatibility rule DE0006 and PowerShell coding guidelines non-generic collections shouldn't be used. In particular relevant for PowerShell would be System.Collections.ArrayList and System.Collections.Hashtable. Most...
Open Graph Description: As per .NET Platform compatibility rule DE0006 and PowerShell coding guidelines non-generic collections shouldn't be used. In particular relevant for PowerShell would be System.Collections.ArrayLis...
X Description: As per .NET Platform compatibility rule DE0006 and PowerShell coding guidelines non-generic collections shouldn't be used. In particular relevant for PowerShell would be System.Collections.Arra...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10315
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"DE0006: Non-generic collections shouldn't be used (especially in Pester tests)","articleBody":"As per [.NET Platform compatibility rule DE0006](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) and [PowerShell coding guidelines](docs/dev-process/coding-guidelines.md) non-generic collections shouldn't be used.\r\n\r\nIn particular relevant for PowerShell would be `System.Collections.ArrayList` and `System.Collections.Hashtable`.\r\n\r\nMost occurrences of `ArrayList` are in C# code obviously, but some can be found in Pester test files too (due to the lack of an internal dynamic array type in PowerShell).\r\n\r\nThose two styles are found in Pester tests:\r\n- `New-Object System.Collections.ArrayList`\r\n- `[System.Collections.ArrayList]::new()`\r\n\r\n**C# code**\r\nThe replacement of the non-generic collections in C# code by the generic ones might be non-trivial due to the type problems. For new code and code changes the rule should be followed as the replacement is an on-going process.\r\n\r\n**Pester tests**\r\nFor Pester test files the PowerShell syntax should be favored over the explicitly typed C# equivalents:\r\n\r\n- `System.Collections.Hashtable` -> `@{}`\r\n- `System.Collections.ArrayList` -> `@()` (though being of type `Array`; in most cases the performance can be neglected using `+=` operator on `@()` on very small arrays; some instances might be refactored to use a `ForEach` loop which returns an `Array`)","author":{"url":"https://github.com/ThreeFive-O","@type":"Person","name":"ThreeFive-O"},"datePublished":"2019-08-07T12:59:01Z","url":"https://github.com/PowerShell/PowerShell/issues/10315"}
| 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:0c8e1184-2f37-3285-0d14-4c82c6635277 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 902E:1D853F:194BB3:223F2E:6AFD4E6B |
| html-safe-nonce | 602cd973e1a423f3df535dcebe17c3700741146511d4144d34bb53f064e0462e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDJFOjFEODUzRjoxOTRCQjM6MjIzRjJFOjZBRkQ0RTZCIiwidmlzaXRvcl9pZCI6IjEwMDc5NDY2MjkwODIwNzQ3MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 123f3dc7a5754afd9aa3781bf34cec99b6ee96b9457cb0d7bbc155a644ed53f2 |
| hovercard-subject-tag | issue:477913803 |
| 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/10315/issue_layout |
| twitter:image | https://opengraph.githubassets.com/22d2add487bcc86c5b672c8415d94bc803b54135745dcae7c7a16d0e3730340d/PowerShell/PowerShell/issues/10315 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/22d2add487bcc86c5b672c8415d94bc803b54135745dcae7c7a16d0e3730340d/PowerShell/PowerShell/issues/10315 |
| og:image:alt | As per .NET Platform compatibility rule DE0006 and PowerShell coding guidelines non-generic collections shouldn't be used. In particular relevant for PowerShell would be System.Collections.ArrayLis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ThreeFive-O |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width