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

[core] Fix tests when converting with PT Locale #23764

Merged
merged 1 commit into from
Jul 23, 2024
Merged

Conversation

rmarinho
Copy link
Member

Description of Change

Make the conversion to string with InvariantCulture so tests also work in computer with different locale.

This pull request includes changes to the ParsePathFigureCollectionToString method in the PathFigureCollectionConverter.cs file. The changes involve updating the way coordinates are converted to strings, specifically switching from the "R" format to using CultureInfo.InvariantCulture.

Here are the key changes:

  • src/Controls/src/Core/Shapes/PathFigureCollectionConverter.cs: Updated the string conversion of various points in the ParsePathFigureCollectionToString method. The ToString method now uses CultureInfo.InvariantCulture instead of the "R" format. This change is applied to the StartPoint of pathFigure, Point of lineSegment, Point1, Point2, and Point3 of bezierSegment, Point1 and Point2 of quadraticBezierSegment, and Point of arcSegment. [1] [2]

@rmarinho rmarinho added area-testing Unit tests, device tests testing-flakiness labels Jul 22, 2024
@rmarinho rmarinho requested a review from a team as a code owner July 22, 2024 18:58
@Eilon
Copy link
Member

Eilon commented Jul 22, 2024

Reading the docs, "R" is used for round-trip support for certain data types, but double is indeed one of them (which is what X and Y are): https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#round-trip-format-specifier-r

So I'm a bit surprised that didn't work here. But, according to the docs the perf of "R" is not great either.

And no matter what, this code change is definitely also correct, so that's good.

Copy link
Member

@Eilon Eilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is good. Could consider adding a test for this too. In the dotnet/aspnet repo there's a CultureReplacer helper class to easily test scenarios where you want to set another culture temporarily to see what effect it has, such as in this test.

So something like that could be used here to test a few cultures and see that we always get back the exact string (in particular, using a culture that we know previously failed).

@rmarinho rmarinho merged commit a117612 into main Jul 23, 2024
95 of 97 checks passed
@rmarinho rmarinho deleted the fix-pathtests branch July 23, 2024 12:57
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-8.0.80 and removed fixed-in-net9.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing Unit tests, device tests fixed-in-8.0.80 fixed-in-net9.0-nightly This may be available in a nightly release! testing-flakiness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants