Decimal128.ToDouble() fails if culture is FR

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 2.10.0
    • Affects Version/s: 2.8.1, 2.9.2, 2.10.0-beta1
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If a class is mapped with BsonType.Double but the underlying type read from the database is Decimal128, the .NET Driver will attempt to convert the Decimal128 value to a double using Decimal128.ToDouble(). The problematic lines are:

      var stringValue = d.ToString();
      return double.Parse(stringValue);
      

      Decimal128.ToString() is hard-coded to format the string using a decimal point. double.Parse(stringValue) does not specify a locale and therefore parses it in the locale of the current thread. In locales such as FR that use a comma as a decimal separate, double.Parse(stringValue) fails. We should be parsing using the CultureInfo.InvariantCulture as we did in CSHARP-1943 for a similar issue.

              Assignee:
              Mikalai Mazurenka (Inactive)
              Reporter:
              James Kovacs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: