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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(many) Make number-to-string conversions use invariant culture #261

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented Jan 24, 2022

I discovered these errors by accident, when trying to run the test suite on Windows (for an entirely different purpose 馃檪). We had some assumptions in the unit tests which failed because the ToString() conversions in .NET uses the CultureInfo.CurrentCulture by default. This means that if you have your Windows running with e.g. Swedish regional settings (which is my setup), a double variable with a value of 123.45 will be rendered as 123,45.

While this is preferable in some contexts, I think we'll go with the "safe and consistent" approach for now, if not for any other reason that the unit/integration tests currently depend on these semantics. It doesn't provide a good dev experience for people trying this out on Windows/with their machine configured to use a different locale, if they would get a bunch of silly errors.

@perlun perlun added bug Something isn't working as expected enhancement New feature or request labels Jan 24, 2022
@perlun perlun added this to the 0.1.0 milestone Jan 24, 2022
else if (@object is IConvertible convertible)
{
// The explicit IFormatProvider is required to ensure we use 123.45 format, regardless of
// host OS language/region settings. See #xxx for more details.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: create a proper issue for this and amend these comments, pointing the reader to the issue in question.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@perlun perlun force-pushed the fix/make-tests-work-on-non-US-cultures branch from b3ec654 to e385c9c Compare January 25, 2022 19:17
@perlun
Copy link
Collaborator Author

perlun commented Jan 25, 2022

(Temporarily cherry-picked the changes from #262 into this branch to ensure that it runs cleanly before merging. We'll need to merge this first and then the other one, because this fixes the underlying problems that the CI PR highlights.)

@perlun
Copy link
Collaborator Author

perlun commented Jan 25, 2022

(Temporarily cherry-picked the changes from #262 into this branch to ensure that it runs cleanly before merging. We'll need to merge this first and then the other one, because this fixes the underlying problems that the CI PR highlights.)

CI is clean. Will fix some remaining issues in this and get it merged, so we can get #262 to also be mergeable (CI clean).

@perlun perlun force-pushed the fix/make-tests-work-on-non-US-cultures branch from e385c9c to 261cf33 Compare January 25, 2022 19:58
@perlun perlun enabled auto-merge (squash) January 25, 2022 19:59
@perlun perlun merged commit b384c74 into master Jan 25, 2022
@perlun perlun deleted the fix/make-tests-work-on-non-US-cultures branch January 25, 2022 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant