Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Respect explicit false for CSV UseCulture#27514

Open
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
KirtiRamchandani:fix/csv-useculture-falseKirtiRamchandani/Powershell:fix/csv-useculture-falseCopy head branch name to clipboard
Open

Respect explicit false for CSV UseCulture#27514
KirtiRamchandani wants to merge 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
KirtiRamchandani:fix/csv-useculture-falseKirtiRamchandani/Powershell:fix/csv-useculture-falseCopy head branch name to clipboard

Conversation

@KirtiRamchandani

@KirtiRamchandani KirtiRamchandani commented May 24, 2026

Copy link
Copy Markdown

PR Summary

Makes CSV commands treat -UseCulture:$false the same as omitting -UseCulture, so the default comma delimiter is used.

PR Context

Fix #26513.

ImportExportCSVHelper.SetDelimiter() previously left the delimiter as the default char value when the active parameter set was a culture parameter set but the UseCulture switch value was explicitly false. This affected multiple CSV commands that share the helper. The helper now falls back to the default CSV delimiter when UseCulture is false, while preserving the culture-specific delimiter when it is true.

Regression tests cover:

  • ConvertTo-Csv -UseCulture:$false
  • Export-Csv -UseCulture:$false
  • Import-Csv -UseCulture:$false
  • ConvertFrom-Csv -UseCulture:$false

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • This PR is focused on one issue
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not work-in-progress
  • Breaking change: No
  • User-facing change: Not required
  • Tests added/updated

Validation

  • Start-PSBuild -PSModuleRestore -UseNuGetOrg
  • Start-PSPester -Path test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Csv.Tests.ps1,test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Csv.Tests.ps1,test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Csv.Tests.ps1,test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertFrom-Csv.Tests.ps1 -UseNuGetOrg -ThrowOnFailure -Terse -SkipTestToolBuild

Result: CSV command tests passed: 92 passed, 0 failed.

Copilot AI review requested due to automatic review settings May 24, 2026 13:49
@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner May 24, 2026 13:49

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds coverage and fixes delimiter selection so that specifying -UseCulture:$false behaves the same as omitting -UseCulture (i.e., uses the default CSV delimiter rather than the culture list separator).

Changes:

  • Add Pester tests validating default delimiter behavior when -UseCulture is explicitly set to $false across Import-Csv, Export-Csv, ConvertTo-Csv, and ConvertFrom-Csv
  • Update SetDelimiter to explicitly pick either the culture list separator (when useCulture is true) or the default CSV delimiter (when false)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Csv.Tests.ps1 Adds test for Import-Csv -UseCulture:$false
test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Csv.Tests.ps1 Adds test asserting comma delimiter when -UseCulture:$false
test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Csv.Tests.ps1 Adds test asserting comma delimiter output when -UseCulture:$false
test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertFrom-Csv.Tests.ps1 Adds test asserting comma delimiter parsing when -UseCulture:$false
src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs Fixes delimiter selection logic for -UseCulture:$false in UseCulture-related parameter sets

Comment on lines +95 to +105
$P1 | Export-Csv -Path $testCsv -UseCulture:$false
$results = Get-Content -Path $testCsv

$results[0] | Should -BeExactly '"P1"'
$results[1] | Should -BeExactly '"first"'

[pscustomobject]@{ H1 = 'V1'; H2 = 'V2' } | Export-Csv -Path $testCsv -UseCulture:$false
$results = Get-Content -Path $testCsv

$results[0] | Should -BeExactly '"H1","H2"'
$results[1] | Should -BeExactly '"V1","V2"'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in f3acfebf6: the CSV tests now set a non-comma culture (de-DE) inside a try block and restore the original culture in finally, so the default-delimiter assertions exercise the intended branch on comma-culture systems too.

$returnObject.Second | Should -Be 2
}

It "Test import-csv with UseCulture explicitly false" {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in f3acfebf6: the Import-Csv test name now uses the same Uses the default delimiter when -UseCulture is explicitly false wording as the related CSV tests.

$returnObject[2] | Should -BeExactly "`"1`"$($delimiter)`"2`""
}

It "Test convertto-csv with UseCulture explicitly false" {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in f3acfebf6: the ConvertTo-Csv test name now uses proper cmdlet casing and matches the shared default-delimiter wording.

Fix ConvertTo-Csv/Export-Csv/Import-Csv/ConvertFrom-Csv delimiter selection
when -UseCulture:$false is passed explicitly. Treat explicit false the same
as omitting the switch and use the default comma delimiter.

Fixes PowerShell#26513
@KirtiRamchandani KirtiRamchandani force-pushed the fix/csv-useculture-false branch from f3acfeb to 396098a Compare June 14, 2026 08:33
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.

ConvertTo-Csv/Export-Csv -UseCulture:$false uses the wrong delimiter in ouput

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.