Repository navigation
[net11] Fix culture-dependent FontSize design-time validation - #39691
Conversation
Validate numeric font sizes using invariant culture and the same number style as the runtime and XAML compiler. Add regression coverage for decimal values, grouping, and custom regional settings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39691Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39691" |
|
Hey there @@noiseonwires! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @noiseonwires! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
No code defects were identified, but CI status and the reported Windows net472 test results remain independently unverified.
No open issues 🎉
What changed in this PR
This PR fixes culture-dependent FontSize validation in MAUI’s design-time tooling so valid XAML numeric literals are not rejected because of regional settings.
Changes:
- Uses
NumberStyles.Numberwith invariant culture for numeric validation, matching runtime and XAML compiler parsing. - Adds 13 regression cases covering multiple cultures and a customized decimal separator, restoring the original culture after each test.
| File | Description |
|---|---|
| src/Controls/tests/Core.Design.UnitTests/FontSizeDesignTypeConverterTests.cs | Adds culture-independent numeric validation regression tests. |
| src/Controls/src/Core.Design/FontSizeDesignTypeConverter.cs | Switches numeric validation to invariant-culture parsing. |
Review effort: Balanced
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit de5e6a4.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Execution log excerptsExecution PR head: de5e6a4b. Without-fix baseline: b20099cf. |
…ion (#39694) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change .NET 10 backport of #39691 (targeting `main`). Fix MAUI's design-time `FontSize` validation so XAML numeric literals are validated using invariant culture, independently of Windows regional settings. The XAML language service uses the design-time converter supplied by MAUI. Its numeric validation calls the current-culture `double.TryParse` overload, while MAUI's runtime and XAML compiler use `NumberStyles.Number` with `CultureInfo.InvariantCulture`. Under `fr-FR`, or an `en-US` culture with the decimal separator customized to a comma, valid XAML such as `FontSize="12.5"` is rejected with XLS0431 even though the app builds and runs. - Use the same invariant numeric parsing settings as the runtime and XAML compiler. - Add 13 regression cases covering `en-US`, `fr-FR`, `de-DE`, invariant decimals and grouping, rejection of localized decimal/grouping combinations, and a custom comma-decimal regional setting. - Restore the original culture in `finally` so tests do not leak culture changes. - Preserve runtime grouping semantics: `12,5` is not a localized spelling of 12.5; the runtime interprets it as 125. Runtime parsing and the XAML language server are unchanged. The source and test changes are identical to #39691; the converter and tests are unchanged between `main` and `inflight/current`. ### Issues Fixed Decimal `FontSize` values can produce false XLS0431 diagnostics and interfere with XAML Hot Reload when the host uses comma-decimal regional settings. Reproduction: change the Windows decimal separator to a comma, restart Visual Studio, debug a MAUI Windows app, and edit a label to use `FontSize="12.5"`. A full `de-DE` locale alone may not reproduce the rejection because its period grouping separator lets the old validator accept the text. ### Validation ```powershell dotnet test src\Controls\tests\Core.Design.UnitTests\Controls.Core.Design.UnitTests.csproj --filter FullyQualifiedName~FontSizeDesignTypeConverterTests ``` - Before the production fix: 5 failed, 29 passed (34 total). - After the production fix: 34 passed, 0 failed. - `dotnet format whitespace` verification passed for both changed files. - `git diff --check` passed. Tests build and run the actual `net472` design tooling on Windows, on top of `inflight/current` (4606786). A complete Visual Studio Hot Reload session was not exercised locally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge the exact published net11.0 tip 426ad52 without flattening or duplicating upstream fixes. Incoming history contains only merged WebView PR #39695 and FontSize PR #39691. All three incoming files had no inflight overlap and merge cleanly; retain every prior corrective commit and inflight-only ancestor. Own-head RTM Android CoreCLR build 1650804 log 123 and Helix403dab35 show the clipping regression as the sole Controls failure (1328 passed, 1 failed, 13 skipped), while all 33 derived Window cases passed. The merged handler matches upstream blob 826a528 exactly. Actual converter-source portable CoreCLR probe passed 13 incoming culture cases plus 4 preserved invariants; original Windows/net472 tests are locally blocked by MSB3644. Whitespace, exact source, clean index and unchanged 11.0.10 version configuration checks passed. Fresh exact-head native/Windows CI remains required. Source-Commit: 1dfcadc Source-Commit: 426ad52 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 87b27872-6f30-4208-af18-f1e6de6ff66c
…ion (#39694) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change .NET 10 backport of #39691 (targeting `main`). Fix MAUI's design-time `FontSize` validation so XAML numeric literals are validated using invariant culture, independently of Windows regional settings. The XAML language service uses the design-time converter supplied by MAUI. Its numeric validation calls the current-culture `double.TryParse` overload, while MAUI's runtime and XAML compiler use `NumberStyles.Number` with `CultureInfo.InvariantCulture`. Under `fr-FR`, or an `en-US` culture with the decimal separator customized to a comma, valid XAML such as `FontSize="12.5"` is rejected with XLS0431 even though the app builds and runs. - Use the same invariant numeric parsing settings as the runtime and XAML compiler. - Add 13 regression cases covering `en-US`, `fr-FR`, `de-DE`, invariant decimals and grouping, rejection of localized decimal/grouping combinations, and a custom comma-decimal regional setting. - Restore the original culture in `finally` so tests do not leak culture changes. - Preserve runtime grouping semantics: `12,5` is not a localized spelling of 12.5; the runtime interprets it as 125. Runtime parsing and the XAML language server are unchanged. The source and test changes are identical to #39691; the converter and tests are unchanged between `main` and `inflight/current`. ### Issues Fixed Decimal `FontSize` values can produce false XLS0431 diagnostics and interfere with XAML Hot Reload when the host uses comma-decimal regional settings. Reproduction: change the Windows decimal separator to a comma, restart Visual Studio, debug a MAUI Windows app, and edit a label to use `FontSize="12.5"`. A full `de-DE` locale alone may not reproduce the rejection because its period grouping separator lets the old validator accept the text. ### Validation ```powershell dotnet test src\Controls\tests\Core.Design.UnitTests\Controls.Core.Design.UnitTests.csproj --filter FullyQualifiedName~FontSizeDesignTypeConverterTests ``` - Before the production fix: 5 failed, 29 passed (34 total). - After the production fix: 34 passed, 0 failed. - `dotnet format whitespace` verification passed for both changed files. - `git diff --check` passed. Tests build and run the actual `net472` design tooling on Windows, on top of `inflight/current` (4606786). A complete Visual Studio Hot Reload session was not exercised locally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
[!NOTE]
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Fix MAUI's design-time
FontSizevalidation so XAML numeric literals are validated using invariant culture, independently of Windows regional settings.The XAML language service uses the design-time converter supplied by MAUI. Its numeric validation currently calls the current-culture
double.TryParseoverload, while MAUI's runtime and XAML compiler useNumberStyles.NumberwithCultureInfo.InvariantCulture. Underfr-FR, or anen-USculture with the decimal separator customized to a comma, valid XAML such asFontSize="12.5"is rejected with XLS0431 even though the app builds and runs.en-US,fr-FR,de-DE, invariant decimals and grouping, rejection of localized decimal/grouping combinations, and a custom comma-decimal regional setting.finallyso tests do not leak culture changes.12,5is not a localized spelling of 12.5; the runtime interprets it as 125. This PR does not change runtime parsing or the XAML language server.Issues Fixed
Decimal
FontSizevalues can produce false XLS0431 diagnostics and interfere with XAML Hot Reload when the host uses comma-decimal regional settings.Reproduction: change the Windows decimal separator to a comma, restart Visual Studio, debug a MAUI Windows app, and edit a label to use
FontSize="12.5". A fullde-DElocale alone may not reproduce the rejection because its period grouping separator lets the old validator accept the text.Validation
dotnet format whitespaceverification passed for both changed files.git diff --checkpassed.Tests build and run the actual
net472design tooling on Windows. A complete Visual Studio Hot Reload session was not exercised locally.A matching .NET 10 fix is being submitted separately against
inflight/current.