Skip to content

fix: format numbers with the current culture - #179

Merged
glennawatson merged 1 commit into
mainfrom
CP_fix-converter-culture
Oct 13, 2026
Merged

glennawatson merged 1 commit into
mainfrom
CP_fix-converter-culture

Conversation

@ChrisPulman

@ChrisPulman ChrisPulman commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Numeric conversions now use the current culture consistently for defaults, format hints, and nullable values in both runtime converters and generated bindings.

  • Align unhinted float formatting with the existing culture-aware numeric converters and parsing.
  • Standardise every TUnit test project's current culture and UI culture to en-US, with explicit fr-FR overrides for culture regressions.
  • Remove host-locale assumptions from converter test inputs and expectations, and add a runnable French-formatting example.

Why

The default SingleToStringTypeConverter used invariant culture while its hinted and nullable forms used current culture. Generated bindings repeated the exception, and converter tests combined locale-aware expectations with fixed dot-decimal text.

Closes #175.

Breaking changes

Unhinted float formatting now follows CultureInfo.CurrentCulture. Applications relying on invariant float output should supply a conversion lambda or custom converter that explicitly uses CultureInfo.InvariantCulture. Public API signatures are unchanged.

How this was verified

Regression tests cover both runtime flavours, nullable values, default and format-hint conversions, generated/runtime parity, and round-trip parsing under English and French cultures. Exercised the full solution build and TUnit suite with the shared culture, the whole runtime suite under both culture probes, and all configured managed examples; both modified production files have complete line and branch coverage.

Native AOT compilation reached native linking, which could not complete because this Windows host lacks advapi32.lib. Linux and Apple execution were unavailable.

Notes for the reviewer

The runtime and generator changes remove the same Single-specific exception. The shared test culture is generated as an assembly attribute from Directory.Build.props; TUnit scopes explicit French overrides to their tests. Companion documentation: reactiveui/website#1005.

This branch starts from main and is independent of #177; it contains none of that PR's property-raiser changes.

Checklist

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

- Align unhinted Single formatting with nullable values, hints, and parsing.
- Generate numeric formatting with the same culture as runtime converters.
- Set en-US as the shared TUnit culture and isolate French culture regressions.
- Make converter test inputs and expectations follow the selected culture.
- Demonstrate numeric formatting with a comma decimal separator.

Closes #175
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.28%. Comparing base (c79c70c) to head (589241d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #179      +/-   ##
==========================================
- Coverage   99.28%   99.28%   -0.01%     
==========================================
  Files         403      403              
  Lines       15033    15032       -1     
  Branches     2229     2228       -1     
==========================================
- Hits        14925    14924       -1     
  Misses        108      108              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@glennawatson
glennawatson merged commit 85fda95 into main Oct 13, 2026
24 checks passed
@glennawatson
glennawatson deleted the CP_fix-converter-culture branch October 13, 2026 04:16
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.

[Bug] Inconsistencies in the Expected Format Provider in Converters

2 participants