Repository navigation
Conversation
DynamicAccessor (CsvSchema.Dynamic) parsed numbers, dates and time spans with the current culture instead of CsvDataReaderOptions.Culture (InvariantCulture by default). On a machine whose culture uses "." as the group separator (de-DE, tr-TR), "12.4" was read as 124. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
CsvSchema.Dynamic,DynamicAccessor.GetValueparsed each field withint/decimal/double/DateTime/TimeSpan.TryParse(str, out ...), which use the current culture (there was a//TODO: culturethere). The other accessors andGetDouble/GetDecimal/... useCsvDataReaderOptions.Culture, which defaults toInvariantCulture. So on a machine whose culture uses.as the group separator (de-DE, tr-TR, ...), the dynamic reader returned124mfor12.4, andCsvDataReaderOptions.Culturehad no effect on dynamic values.This passes the reader's culture to those
TryParsecalls, with the sameNumberStyles/DateTimeStylesthe culture-less overloads use (Integer,Number,Float | AllowThousands,None), so the accepted formats don't change. The reader gets an internalCultureproperty for the accessor.Test:
CsvDataReaderTests.DynamicSchemaUsesReaderCulturesets the current culture to de-DE and checks that12.4and1.5e3are read as12.4mand1500dwith the default options, and that12,4is read as12.4mwithCulture = de-DE. It fails onmaster(Actual: 124) and passes with this change. On this machine (tr-TR) the existingDynamicSchemaandDynamicReadertests also failed onmasterfor the same reason and pass now.What I ran (Windows, tr-TR): built
Sylvan.Data.Csvfor all target frameworks,dotnet test source/Sylvan.Data.Csv.Tests -f net8.0: 237 passed, 8 skipped, 0 failed.Written with Claude Code (AI); I reviewed the change and ran the tests above.
🤖 Generated with Claude Code