-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
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.