[CSHARP-2821] Decimal128.ToDouble() fails if culture is FR Created: 28/Oct/19  Updated: 28/Oct/23  Resolved: 19/Nov/19

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.8.1, 2.9.2, 2.10.0-beta1
Fix Version/s: 2.10.0

Type: Bug Priority: Major - P3
Reporter: James Kovacs Assignee: Mikalai Mazurenka (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Case:

 Description   

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.



 Comments   
Comment by Githook User [ 19/Nov/19 ]

Author:

{'name': 'Mikalai Mazurenka', 'username': 'MikalaiMazurenka', 'email': 'mikalai.mazurenka@mongodb.com'}

Message: CSHARP-2821: Decimal128.ToDouble() fails if culture is FR
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/79faa5fc6a51c4a7e1ea78d116596a2058e482f2

Generated at Wed Feb 07 21:43:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.