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

always take InvariantCulture when parsing floats #1971

Merged
merged 1 commit into from
Apr 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Microsoft.Toolkit.Uwp.UI/Extensions/Visual/VisualExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// ******************************************************************

using System;
using System.Globalization;
using System.Linq;
using System.Numerics;
using Windows.UI.Composition;
Expand Down Expand Up @@ -50,11 +51,11 @@ public static Vector2 ToVector2(this string str)

if (count == 1)
{
vector = new Vector2(float.Parse(values[0]));
vector = new Vector2(float.Parse(values[0], CultureInfo.InvariantCulture));
}
else if (count == 2)
{
vector = new Vector2(float.Parse(values[0]), float.Parse(values[1]));
vector = new Vector2(float.Parse(values[0], CultureInfo.InvariantCulture), float.Parse(values[1], CultureInfo.InvariantCulture));
}
else
{
Expand Down Expand Up @@ -95,11 +96,14 @@ public static Vector3 ToVector3(this string str)

if (count == 1)
{
vector = new Vector3(float.Parse(values[0]));
vector = new Vector3(float.Parse(values[0], CultureInfo.InvariantCulture));
}
else if (count == 3)
{
vector = new Vector3(float.Parse(values[0]), float.Parse(values[1]), float.Parse(values[2]));
vector = new Vector3(
float.Parse(values[0], CultureInfo.InvariantCulture),
float.Parse(values[1], CultureInfo.InvariantCulture),
float.Parse(values[2], CultureInfo.InvariantCulture));
}
else
{
Expand Down Expand Up @@ -140,11 +144,15 @@ public static Vector4 ToVector4(this string str)

if (count == 1)
{
vector = new Vector4(float.Parse(values[0]));
vector = new Vector4(float.Parse(values[0], CultureInfo.InvariantCulture));
}
else if (count == 4)
{
vector = new Vector4(float.Parse(values[0]), float.Parse(values[1]), float.Parse(values[2]), float.Parse(values[3]));
vector = new Vector4(
float.Parse(values[0], CultureInfo.InvariantCulture),
float.Parse(values[1], CultureInfo.InvariantCulture),
float.Parse(values[2], CultureInfo.InvariantCulture),
float.Parse(values[3], CultureInfo.InvariantCulture));
}
else
{
Expand Down