Skip to content

Conversation

@blanca-negrete
Copy link

@blanca-negrete blanca-negrete commented Dec 1, 2025

PR Summary

Fix #26513

Fixes behavior where ConvertTo-Csv and Export-Csv incorrectly used the culture-specific delimiter even when explicitly passed -UseCulture:$false. When UseCulture is set to $false, the commands now correctly fall back to the default comma (,) delimiter.

PR Context

-UseCulture:$false was not being treated the same as omitting -UseCulture.
This resulted in inconsistent delimiter behavior, especially in cultures that use ; as the list separator.
This PR updates ImportExportCSVHelper.SetDelimiter to ensure that UseCulture:$false properly defaults to the standard CSV delimiter.

PR Checklist

else
{
delimiter = ImportExportCSVHelper.CSVDelimiter;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use conditional operator.

delimiter = useCulture ? ... : ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

@blanca-negrete Please address my request.

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Dec 3, 2025
@surfingoldelephant
Copy link

surfingoldelephant commented Dec 4, 2025

The PR needs to be marked as fixing issue:

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Dec 11, 2025
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where ConvertTo-Csv and Export-Csv incorrectly used the culture-specific delimiter even when explicitly passed -UseCulture:$false. The fix ensures that when UseCulture is explicitly set to $false, the commands correctly fall back to the default comma (,) delimiter instead of using the culture-specific list separator.

Key Changes

  • Added an else block in ImportExportCSVHelper.SetDelimiter to handle the case when useCulture is false, ensuring it falls back to the default CSV delimiter (comma)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1806 to +1809
else
{
delimiter = ImportExportCSVHelper.CSVDelimiter;
}
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

This fix for handling UseCulture:$false correctly lacks test coverage. While the fix itself is correct, automated tests should be added to verify that:

  1. When -UseCulture:$false is explicitly specified, the default comma delimiter is used (not the culture-specific delimiter)
  2. When -UseCulture is omitted, the default comma delimiter is used
  3. When -UseCulture or -UseCulture:$true is specified, the culture-specific delimiter is used

These tests would prevent regression of issue #26513 and can be added to the existing test files (e.g., ConvertTo-Csv.Tests.ps1 or ImportExportCSV.Delimiter.Tests.ps1).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Review - Needed The PR is being reviewed

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

3 participants