Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed culture sensitivity when parsing AspectRatio components #4253

Conversation

Sergio0694
Copy link
Member

Fixes #4252

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The AspectRatio.ConvertToAspectRatio(string) method used for parsing is using Convert.ToDouble, which by default uses the current culture for parsing. This causes a crash when trying to parse a number using '.' as decimal separator on cultures that instead use ',' as decimal separator (eg. French, Italian). Furthermore, the parsing behavior is not consistent with eg. the various Vector2/3/4 and Quaternion parsing APIs in the StringExtensions class in Microsoft.Toolkit.Uwp.UI.

What is the new behavior?

Updated the parsing logic in AspectRatio.ConvertToAspectRatio(string) to be consistent with other parsing APIs.
The parsing is now done using CultureInfo.InvariantCulture, which fixes the crash reported in the linked issue.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@Sergio0694 Sergio0694 added bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ hotfix 🌶 priority 🚩 labels Sep 16, 2021
@Sergio0694 Sergio0694 added this to the 7.1 milestone Sep 16, 2021
@ghost
Copy link

ghost commented Sep 16, 2021

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@Sergio0694 Sergio0694 force-pushed the bugfix/aspectratio-localized-parsing branch from 3488556 to 7642602 Compare September 16, 2021 09:15
@Rosuavio Rosuavio merged commit 0dfba3b into CommunityToolkit:main Sep 16, 2021
@Sergio0694 Sergio0694 deleted the bugfix/aspectratio-localized-parsing branch September 16, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ hotfix 🌶 priority 🚩
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConstrainedBox crashes with all cultures not using '.' as the decimal separator
4 participants