Explorar o código

Fix culture issues for floating point types in config files

Bepis %!s(int64=5) %!d(string=hai) anos
pai
achega
1348da9e4b
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  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),
 			},
 		};