Repository navigation
[Runtime] Create usCulture without user overrides - #2100
Merged
RobertvanderHulst merged 1 commit intoOct 14, 2026
Merged
Conversation
ConversionHelpers.usCulture (XSharp.Core and XSharp.RT) was created with
CultureInfo{"en-US"}, which applies the Windows user overrides. When the
user format is "English (United States)" with decimal symbol "," and digit
grouping ".", Val("0.9999999999") returned 9999999999, because
NumberStyles.Number treats "." as a group separator. Str()/Transform()
emitted "," and ignored SetDecimalSep().
Use CultureInfo{"en-US", false} so the reference culture always uses
"." / ",". Add tests for the invariant and a test that reproduces the
bug by swapping usCulture.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Hansjoerg and Claude, good catch! |
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.
Problem
ConversionHelpers.usCulture(XSharp.CoreConvert.prg, XSharp.RTConversions.prg) is meant to be a fixed reference culture, but it is created withCultureInfo{"en-US"}, which applies the user's overrides. When the Windows format is "English (United States)" with the decimal symbol changed to,and digit grouping to.,_VOVal/_Valparse withNumberStyles.Numberand treat.as a group separator. Nothing raises an error; the numbers are just wrong.FormatNumber(Str/NTrim/Transform) has the same problem and outputs,regardless ofSetDecimalSep().Repro (on such a machine)
Val("0.9999999999")→9999999999. In plain .NET:Fix
CultureInfo{"en-US", false}in both assemblies. Unaffected users see no change; InvariantCulture was deliberately not used.Tests
New
UsCulturecollection (parallelization disabled) in XSharp.Core.Tests and XSharp.RT.Tests:UseUserOverride == falseand the./,separators.Val("0.99")→ 99 andStr(1.5,4,1)→" 1,5", then restores the original culture and checks the correct results.The invariant tests fail without the fix and pass with it. The rest of the Core/RT suites shows the same order-dependent failures with and without this change (shared global state such as Dialect/SetDecimalSep across parallel test classes).
🤖 Generated with Claude Code