Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ComponentModel.TypeConverterTests.SizeFConverterTests failing for locale en-DE #25862

Closed
FreezyLemon opened this issue Apr 12, 2018 · 8 comments
Labels
area-System.ComponentModel backlog-cleanup-candidate An inactive issue that has been marked for automated closure. bug no-recent-activity

Comments

@FreezyLemon
Copy link
Contributor

<test name="System.ComponentModel.TypeConverterTests.SizeFConverterTests.ConvertFromString(width: 3,402823E+38, height: 3,402823E+38)" type="System.ComponentModel.TypeConverterTests.SizeFConverterTests" method="ConvertFromString" time="1.3487067" result="Fail">
  <failure exception-type="System.ArgumentException">
    <message><![CDATA[System.ArgumentException : 40282347e+38 is not a valid value for Single.\r\nParameter name: value\r\n---- System.OverflowException : Value was either too large or too small for a Single.]]></message>
    <stack-trace><![CDATA[   at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\ComponentModel\BaseNumberConverter.cs:line 85
   at System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, String text) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\ComponentModel\TypeConverter.cs:line 107
   at System.Drawing.SizeFConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\Drawing\SizeFConverter.cs:line 61
   at System.ComponentModel.TypeConverter.ConvertFromString(String text) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\ComponentModel\TypeConverter.cs:line 91
   at System.ComponentModel.TypeConverterTests.SizeFConverterTests.ConvertFromString(Single width, Single height) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\tests\Drawing\SizeFConverterTests.cs:line 234
----- Inner Stack Trace -----
   at System.Number.ParseSingle(ReadOnlySpan`1 value, NumberStyles options, NumberFormatInfo numfmt) in E:\A\_work\104\s\src\mscorlib\shared\System\Number.Parsing.cs:line 793
   at System.Single.Parse(String s, NumberStyles style, IFormatProvider provider) in E:\A\_work\104\s\src\mscorlib\shared\System\Single.cs:line 288
   at System.ComponentModel.SingleConverter.FromString(String value, NumberFormatInfo formatInfo) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\ComponentModel\SingleConverter.cs:line 39
   at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) in D:\DEV\corefx\src\System.ComponentModel.TypeConverter\src\System\ComponentModel\BaseNumberConverter.cs:line 80]]></stack-trace>
  </failure>
</test>

The problem here seems to be that german numbers use the comma (,) as a decimal separator instead of a dot (.):

https://github.com/dotnet/corefx/blob/73214ff6da537eb9dcf522406ef1d0470b88db88/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs#L55-L62

text is the input string to be converted.
In en-us, the decimal point is represented by . and ListSeparator is ,
-> text == "3.402823E+38, 3.402823E+38"

In de-de (the "normal" german locale), the decimal point is , and ListSeparator is ;
-> text == "3,402823E+38; 3,402823E+38"

Since this locale mixes the two, unfortunately the two are the same:
text == "3,402823E+38, 3,402823E+38"

This seems to break the code since tokens is not splitting the numbers correctly here, leading to the exception.

@danmoseley
Copy link
Member

@Anipik not seen in Spanish os?

@Anipik
Copy link
Contributor

Anipik commented Apr 12, 2018

No, the failure is not seen in Spanish. Even in Spanish the decimal separator is “,”

@FreezyLemon
Copy link
Contributor Author

FreezyLemon commented Apr 12, 2018

I'd assume that the ListSeparator in spanish is also something like ; though?
It might not be clear from my first post, but I'm pretty sure that this happens because the decimal separator is the same character as the ListSeparator, which results in

char sep = culture.TextInfo.ListSeparator[0]; 
string[] tokens = text.Split(sep); 

splitting the input text wrongly.

So instead of two tokens containing 3.402823E+38, it splits it into four tokens:
3
402823E+38
3
402823E+38

@Anipik
Copy link
Contributor

Anipik commented Apr 12, 2018

@Anipik
Copy link
Contributor

Anipik commented Apr 12, 2018

The List separator for Spanish is ";"

@FreezyLemon
Copy link
Contributor Author

FreezyLemon commented Apr 12, 2018

en-US passes the tests.
I tried some other "combinations" that should have this problem, and the only one I could find apart from "en-DE" (my computer) is "en-SE" (sweden). a lot of locales like en-FR, en-IT, en-DA, do not have this issue as they also use the dot . as a decimal separator.

It seems like my assumptions above were correct, even though this only applies to a few (?) locale choices

EDIT: en-DK also fails, I misspelled it as "en-DA" before

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@ericstj ericstj removed the untriaged New issue has not been triaged by the area owner label Jul 1, 2020
Copy link
Contributor

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

@dotnet-policy-service dotnet-policy-service bot added backlog-cleanup-candidate An inactive issue that has been marked for automated closure. no-recent-activity labels Jan 1, 2025
Copy link
Contributor

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@dotnet-policy-service dotnet-policy-service bot removed this from the Future milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.ComponentModel backlog-cleanup-candidate An inactive issue that has been marked for automated closure. bug no-recent-activity
Projects
None yet
Development

No branches or pull requests

6 participants