Title: Treating System.Data.DataTable as enumerable clashes with member-access enumeration · Issue #6466 · PowerShell/PowerShell · GitHub
Open Graph Title: Treating System.Data.DataTable as enumerable clashes with member-access enumeration · Issue #6466 · PowerShell/PowerShell
X Title: Treating System.Data.DataTable as enumerable clashes with member-access enumeration · Issue #6466 · 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":"Treating System.Data.DataTable as enumerable clashes with member-access enumeration","articleBody":"In the pipeline, `[System.Data.DataTable]` is still treated as a _collection_ that implicitly enumerates its `.Rows` collection - through a mechanism that is unclear to me, given that it in other contexts this is currently, though possibly only temporarily, disabled (see #6453).\n\nGiven that `[System.Data.DataTable]`:\n\n* itself has no `.Count` property\n* is not itself indexable\n\nthe behavior with member-access enumeration - use of `.Count` and indexing - is not as expected:\n\nSteps to reproduce\n------------------\n\n```powershell\n# Create a sample data table with 2 rows.\n1..2 | % { $dt = [Data.DataTable]::new(\"test\") } { $dt.Rows.Add($dt.NewRow()) }\n\n# If we assume that [DataTable] is a collection, this should be equal to $dt.Rows.Count, i.e., 2\n$dt.Count\n\n# If we assume that [DataTable] is an indexable collection, this should return the\n# type name of the 2nd row, $dt.Rows[1], i.e., 'DataRow'\n$dt[1].GetType().Name\n```\n\nExpected behavior\n-----------------\n\n```none\n2\nDataRow\n```\n\nNote: If [DataTable] itself is NOT conceived of as a collection, the expected behavior would be:\n\n```none\n1 # a single [DataTable] instance\nYou cannot call a method on a null-valued expression. # Error, because index 1 doesn't exist.\n...\n```\n\nActual behavior\n---------------\n\n```none\n1 # post-#5756 only: member enumeration was applied to the items of .Row\n1 # ditto\nYou cannot call a method on a null-valued expression. # Error, index 1 was applied to $dt itself, not the .Rows collection\n...\n```\n\nNote: `$dt.Count` returning `1, 1` is only seen with @iSazonov's #5756 PR in effect, which has not been released yet as of PowerShell Core v6.0.2; without it, `$null` is output, because the row objects lack the implicit `.Count` property.\n\nEnvironment data\n----------------\n\n\u003c!-- provide the output of $PSVersionTable -->\n\n```powershell\nPowerShell Core v6.0.2 on macOS 10.13.3\nPowerShell Core v6.0.2 on Ubuntu 16.04.3 LTS\nPowerShell Core v6.0.2 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\nWindows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\n```\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-03-22T19:13:31Z","url":"https://github.com/PowerShell/PowerShell/issues/6466"}
| 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:30ff980c-a5f8-f70e-a14b-6a0b91f2d9aa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F32:3FAC3:61F659:8CEAA0:6AFD8D69 |
| html-safe-nonce | fcc491b50ec375896435b6edd8da5ed79399ba5e85d4c4a8f4a6220ee5aed81d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjMyOjNGQUMzOjYxRjY1OTo4Q0VBQTA6NkFGRDhENjkiLCJ2aXNpdG9yX2lkIjoiNjA2NzkwODE5ODE5MzI3MDEyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 585433769c332706475f6c2896f660c29d6e6107b8ff3fdbde8fbf1154e834d0 |
| 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/6466 |
| 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 | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| 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 | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width