Selaa lähdekoodia

Fix culture issues for floating point types in config files

Bepis 5 vuotta sitten
vanhempi
commit
1348da9e4b
1 muutettua tiedostoa jossa 7 lisäystä ja 6 poistoa
  1. 7 6
      BepInEx/Configuration/TomlTypeConverter.cs

+ 7 - 6
BepInEx/Configuration/TomlTypeConverter.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 
 namespace BepInEx.Configuration
 {
@@ -76,18 +77,18 @@ namespace BepInEx.Configuration
 
 			[typeof(float)] = new TypeConverter
 			{
-				ConvertToString = (obj) => obj.ToString(),
-				ConvertToObject = (str) => float.Parse(str),
+				ConvertToString = (obj) => ((float)obj).ToString(NumberFormatInfo.InvariantInfo),
+				ConvertToObject = (str) => float.Parse(str, NumberFormatInfo.InvariantInfo),
 			},
 			[typeof(double)] = new TypeConverter
 			{
-				ConvertToString = (obj) => obj.ToString(),
-				ConvertToObject = (str) => double.Parse(str),
+				ConvertToString = (obj) => ((double)obj).ToString(NumberFormatInfo.InvariantInfo),
+				ConvertToObject = (str) => double.Parse(str, NumberFormatInfo.InvariantInfo),
 			},
 			[typeof(decimal)] = new TypeConverter
 			{
-				ConvertToString = (obj) => obj.ToString(),
-				ConvertToObject = (str) => decimal.Parse(str),
+				ConvertToString = (obj) => ((decimal)obj).ToString(NumberFormatInfo.InvariantInfo),
+				ConvertToObject = (str) => decimal.Parse(str, NumberFormatInfo.InvariantInfo),
 			},
 		};