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

Tests in PerformanceTrackerServiceTests fail when the current English language culture uses a different number format #39248

Closed
castholm opened this issue Oct 12, 2019 · 0 comments · Fixed by #39254
Labels
Area-Infrastructure Contributor Pain The issue impedes progress for project collaborators. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@castholm
Copy link
Contributor

When running the included tests on my Windows 10 machine, which has its display language set to English (United States) and its regional settings set to English (Sweden) (en-SE), four of the five tests in the PerformanceTrackerServiceTests class fail with the message "System.InvalidOperationException : Sequence contains no elements".

Digging a bit deeper shows that the cause of the exception is a section of code in the PerformanceTrackerServiceTests.CreateMatrix() method which tries to parse numeric values like 7.0 as doubles and fails to do so because the en-SE culture has its decimal separator set to a comma and not a period.

The format provider used to parse the numbers is resolved via EnsureEnglishUICulture.PreferredOrNull, which returns null if CultureInfo.CurrentUICulture.Name starts with "en" and CultureInfo.InvariantCulture otherwise. The intention seems to be to always try to fall back to the current culture if it appears to be a common English language culture like en-US or en-UK that have a lot of formatting settings in common, but this doesn't always work when the current culture is en-SE or some other less common culture.

I have fixed this issue locally by simply forcing the use of CultureInfo.InvariantCulture when parsing the numeric values in these particular tests, but I think it could also be worth looking into EnsureEnglishUICulture.PreferredOrNull and maybe restricting it to a strict subset of English language cultures that are known to work. Let me know if you would like me to submit my proposed changes as a pull request.

@sharwell sharwell added Area-Infrastructure Contributor Pain The issue impedes progress for project collaborators. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Oct 12, 2019
@jinujoseph jinujoseph added this to the 16.4.P3 milestone Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure Contributor Pain The issue impedes progress for project collaborators. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants