Fix inconistent minus sign with different culture#46588
Fix inconistent minus sign with different culture#46588buyaa-n merged 5 commits intodotnet:masterfrom
Conversation
|
Tagging subscribers to this area: @buyaa-n, @krwq Issue DetailsFixes #45952 XContainer.cs using XmlConvert.ToString(...) overloads for converting some numeric types like float, double, decimal types which uses Invariant culture internally. For other numeral like int, long, short ets converted using Object.ToString() which converts the numbers with default culture which is causing the minus sign (-) converted differently for some cultures like Swedish, they all should converted by XmlConvert.ToString(...) which uses Invariant culture.
|
src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs
Outdated
Show resolved
Hide resolved
| { | ||
| newCulture = new CultureInfo("SE-SW"); | ||
| } | ||
| catch (CultureNotFoundException) { /* Do nothing */ } |
There was a problem hiding this comment.
should it return in the catch block? ie on a machine where for some reason does not have this culture, you want it to silently continue and use the current culture instead?
There was a problem hiding this comment.
Yeah, i want it continue even the culture not found, because i don't see much test in this class, so still is not useless, plus the issue could happen for other culture too, wherever the test run its worth testing it
|
@danmosemsft @jkotas please let me know if you have any other comments/concerns |
|
ltgm |
Fixes #45952
XContainer.cs using XmlConvert.ToString(...) overloads for converting some numeric types like float, double, decimal types which uses Invariant culture internally. For other numeral like int, long, short ets converted using Object.ToString() which converts the numbers with default culture which is causing the minus sign (-) converted differently for some cultures like Swedish, they all should converted by XmlConvert.ToString(...) which uses Invariant culture.