[Bug 46842] C# double.TryParse( String.Empty, out number) succeeds with .NET Framework 4.0 when it should not

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Mar 15 12:38:55 CDT 2019


https://bugs.winehq.org/show_bug.cgi?id=46842

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|c# On Wine double.TryParse  |C# double.TryParse(
                   |successfully converts empty |String.Empty, out number)
                   |string to a double. But     |succeeds with .NET
                   |double is corrupt.          |Framework 4.0 when it
                   |                            |should not
           Keywords|                            |dotnet

--- Comment #4 from Anastasius Focht <focht at gmx.net> ---
Hello IanS,

I've tested all kinds of Wine versions and .NET Framework combinations
(including default Wine-Mono) and can't reproduce this.

Using a more elaborate example from Microsoft docs which also covers your case
"" -> String.Empty:

https://docs.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=netframework-4.7.2

I've modified it a bit as 'var' was introduced with C# 3.0 (just want to use
.NET Framework 2.0).

--- snip ---
using System;

public class Example
{
   public static void Main()
   {
      string[] values = { "1,643.57", "$1,643.57", "-1.643e6", 
                          "-168934617882109132", "123AE6", 
                          null, String.Empty, "ABCDEF" };
      double number;

      foreach (string value in values) {
         if (Double.TryParse(value, out number)) 
            Console.WriteLine("'{0}' --> {1}", value, number);
         else
            Console.WriteLine("Unable to parse '{0}'.", value);      
      }   
   }
}
// The example displays the following output:
//       '1,643.57' --> 1643.57
//       Unable to parse '$1,643.57'.
//       '-1.643e6' --> -1643000
//       '-168934617882109132' --> -1.68934617882109E+17
//       Unable to parse '123AE6'.
//       Unable to parse ''.
//       Unable to parse ''.
//       Unable to parse 'ABCDEF'.
--- snip ---

'winetricks -q dotnet20sdk' to get C# compiler 'csc.exe'.

Compile it to .NET executable using the SDK C# compiler.

--- snip ---
$ wine "c:\\windows\\Microsoft.NET\\Framework\\v2.0.50727\\csc.exe" /debug+
bug46842.cs
...
--- snip ---

Running with Wine 4.3 and Wine-Mono 4.x (4.8.5) in fresh WINEPREFIX:

--- snip ---
$ wine ./bug46842.exe 
'1,643.57' --> 1643.57
Unable to parse '$1,643.57'.
'-1.643e6' --> -1643000
'-168934617882109132' --> -1.68934617882109E+17
Unable to parse '123AE6'.
Unable to parse ''.
Unable to parse ''.
Unable to parse 'ABCDEF'.
--- snip ---

Running with Wine 4.3 and Microsoft .NET Framework 2.0 installed ('winetricks
-q dotnet20'):

--- snip ---
$ wine ./bug46842.exe
'1,643.57' --> 1643.57
Unable to parse '$1,643.57'.
'-1.643e6' --> -1643000
'-168934617882109132' --> -1.68934617882109E+17
Unable to parse '123AE6'.
Unable to parse ''.
Unable to parse ''.
Unable to parse 'ABCDEF'.
--- snip ---

Running with Wine 4.3 and Microsoft .NET Framework 4.0 installed ('winetricks
-q dotnet40').
Added app config 'bug46842.exe.config' to avoid 'Unable to find a version of
the runtime to run this application.' error:

--- snip ---
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v2.0.50727" />
        <supportedRuntime version="v4.0" />
    </startup>
</configuration>
--- snip ---

--- snip ---
$ wine --version
wine-4.3-439-gfa26231748

$ wine ./bug46842.exe 
'1,643.57' --> 1643.57
Unable to parse '$1,643.57'.
'-1.643e6' --> -1643000
'-168934617882109132' --> -1.68934617882109E+17
Unable to parse '123AE6'.
Unable to parse ''.
Unable to parse ''.
Unable to parse 'ABCDEF'.
--- snip ---

Running with Wine 3.0 and Microsoft .NET Framework 4.0 installed ('winetricks
-q dotnet40').

--- snip ---
$ wine --version
wine-3.0

$ wine ./bug46842.exe 
'1,643.57' --> 1643.57
Unable to parse '$1,643.57'.
'-1.643e6' --> -1643000
'-168934617882109132' --> -1.68934617882109E+17
Unable to parse '123AE6'.
Unable to parse ''.
Unable to parse ''.
Unable to parse 'ABCDEF'.
--- snip ---

Plain Wine works as intended. Hard to tell what is wrong with your setup. 
Also 'PlayOnLinux' is not supported here.

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list