Skip to content

Parse and write UINumberInput values with the invariant culture - #1700

Open
menes97 wants to merge 1 commit into
DevToys-app:mainfrom
menes97:fix/number-input-invariant-culture
Open

menes97 wants to merge 1 commit into
DevToys-app:mainfrom
menes97:fix/number-input-invariant-culture

Conversation

@menes97

@menes97 menes97 commented Nov 18, 2026

Copy link
Copy Markdown

Pull request type

  • Bugfix
  • New feature or enhancement
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

UINumberInput.Value parses Text with double.TryParse(Text, out var value) and GUI.Value(this IUINumberInput, double) writes it back with safeValue.ToString(), both in the current culture. The Blazor presenter renders the control as an HTML number input (TextBoxTypes.Number), whose text always uses . as the decimal separator. On a machine with the Turkish culture (and others with , as the decimal separator):

  • "1.5" is parsed as 15 (. is the group separator there);
  • Value(1.5) writes "1,5", which a number input doesn't accept.

What is the new behavior?

  • Value parses with NumberStyles.Float and CultureInfo.InvariantCulture.
  • GUI.Value(...) writes with ToString(CultureInfo.InvariantCulture).
  • New UINumberInputTests (tr-TR set inside the tests): Value_ParsesTextWithInvariantCulture and ValueExtension_WritesTextWithInvariantCulture. Both fail without the change (Expected: 1,5, Actual: 15 and Expected: "1.5", Actual: "1,5") and pass with it.

Other information

Found by reading the code, not from an issue. I didn't run the app UI, so the number input's separator behaviour comes from the presenter code, not from observing it. The change only matters for tools that use GUI.NumberInput / GUI.Value. Locally I pinned global.json to the SDK I have (8.0.100 isn't installed); that change isn't in the commit.

This change was written with Claude Code.

Quality check

  • Did you follow the code style guideline as described in CONTRIBUTING.md
  • Did you build the app and test your changes? (built and ran unit tests; did not run the app UI)
  • Did you check for accessibility? On Windows, you can use Accessibility Insights for this.
  • Did you verify that the change work in Release build configuration
  • Did you verify that all unit tests pass (DevToys.UnitTests 152/152, net8.0)
  • If necessary and if possible, did you verify your changes on:
    • Windows
    • macOS
    • Linux

🤖 Generated with Claude Code

The HTML number input always exchanges its text with '.' as the decimal
separator, but UINumberInput.Value parsed it, and GUI.Value wrote it, with
the current culture. In cultures such as tr-TR, "1.5" was read as 15 and
Value(1.5) wrote "1,5", which the number input rejects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant