Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2821

Decimal128.ToDouble() fails if culture is FR

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.10.0
    • Affects Version/s: 2.8.1, 2.9.2, 2.10.0-beta1
    • Component/s: BSON
    • 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@mongodb.com Mikalai Mazurenka (Inactive)
            Reporter:
            james.kovacs@mongodb.com James Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: