-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix UseCulture: behavior for CSV delimiter #26513 #26551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix UseCulture: behavior for CSV delimiter #26513 #26551
Conversation
| else | ||
| { | ||
| delimiter = ImportExportCSVHelper.CSVDelimiter; | ||
| } |
There was a problem hiding this comment.
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 ? ... : ...There was a problem hiding this comment.
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.
|
The PR needs to be marked as fixing issue: |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
There was a problem hiding this 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
elseblock inImportExportCSVHelper.SetDelimiterto handle the case whenuseCultureisfalse, ensuring it falls back to the default CSV delimiter (comma)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else | ||
| { | ||
| delimiter = ImportExportCSVHelper.CSVDelimiter; | ||
| } |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
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:
- When -UseCulture:$false is explicitly specified, the default comma delimiter is used (not the culture-specific delimiter)
- When -UseCulture is omitted, the default comma delimiter is used
- 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).
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
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header