Skip to content

DataRow: Unwrap PSObject values when assigning columns - #28221

Open
lsmlhi_25 (FOWEPJF255) wants to merge 1 commit into
PowerShell:masterfrom
FOWEPJF255:fix/datarow-psobject-assignment
Open

lsmlhi_25 (FOWEPJF255) wants to merge 1 commit into
PowerShell:masterfrom
FOWEPJF255:fix/datarow-psobject-assignment

Conversation

@FOWEPJF255

Copy link
Copy Markdown

PR Summary

Unwrap PSObject values during DataRow and DataRowView assignment so PowerShell-produced values such as DateTime are accepted by .NET data columns.

PR Context

The Get-Date repro in #17627 fails on current PowerShell because DataRow receives a PSObject wrapper instead of the wrapped DateTime. This change unwraps values in DataRow and DataRowView property setters and in object-valued indexer setters for those two types. Regression tests cover property and indexer assignments to DateTime columns on both types.

A similar fix was proposed in #19071. That PR was closed without merging on 2026-10-08. This PR revalidates the focused behavior against current master and adds regression coverage.

Fixes #17627

Verification

  • Start-PSBuild -Configuration Debug -UseNuGetOrg -SkipRoslynAnalyzers passed with the repository-pinned .NET SDK 11.0.100-rc.1.
  • Start-PSPester -Path test/powershell/engine/ETS/Adapter.Tests.ps1 -Tag CI -ThrowOnFailure -Terse passed: 34 passed, 0 failed, 3 pending.
  • The assignment repro against the built pwsh passed for both DataRow property and indexer setters.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes.
  • Summarized changes.
  • Modified .cs and .ps1 files have the correct Microsoft copyright and license headers; no new source files were added.
  • This PR is ready to merge and is not a work in progress.
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • Added and ran regression tests.

Unwrap PSObject values for DataRow and DataRowView property and indexer assignments. Add regression coverage for DateTime columns.

Fixes PowerShell#17627
@FOWEPJF255
lsmlhi_25 (FOWEPJF255) requested a review from a team as a code owner October 16, 2026 04:41
Copilot AI balanced review requested due to automatic review settings October 16, 2026 04:41
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are narrowly scoped, cover both assignment paths with regression tests, and have no unresolved findings.

0 open findings

What changed in this PR

Fixes #17627 by unwrapping PSObject values before assigning data columns, allowing PowerShell-produced values such as Get-Date results.

Changes:

  • Updates property and indexer setters for DataRow and DataRowView.
  • Adds regression tests for both assignment forms and types.
File Description
test/​powershell/​engine/​ETS/​Adapter.Tests.ps1 Tests wrapped DateTime assignments.
src/​System.Management.Automation/​engine/​runtime/​Binding/​Binders.cs Unwraps values for the affected indexer setters.
src/​System.Management.Automation/​engine/​CoreAdapter.cs Unwraps values in both property setters.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression bug 7.2.0 - Unable to cast DateTime into DataRow DateTime column

2 participants