.net double misbehaves

Questions about Wine on Linux
Locked
IanS
Newbie
Newbie
Posts: 3
Joined: Fri Mar 15, 2019 9:44 am

.net double misbehaves

Post by IanS »

I'm the author/developer of an Inventory program that's been available on Windows for around 20 years.

I was curious about how easy it would be to make the application work on Wine/Linux. It works surprisingly well. :D

But I'm curious about one thing. See the following code. .Net application written in C#.

Code: Select all

double d = 0;
string s = ""; // Create an empty string.

if (double.TryParse(s, out d) == true)
        MessageBox.Show( d.ToString() );

That code should not display the messagebox. TryParse should not successfully parse an empty string.
But when running on Wine/Mint tryparse of an empty string returns true and the messagebox shows an empty string showing the d (the double) is empty. :evil:

What is d? Is it corrupt? It's not a number. What is it?

Thanks
IanS
Newbie
Newbie
Posts: 3
Joined: Fri Mar 15, 2019 9:44 am

Re: .net double misbehaves

Post by IanS »

Just wanted to add the the problem only occurs when running on MS.Net in Wine (Linux Mint 19.1)

If I run on Mono (without wine) there is no problem.
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: .net double misbehaves

Post by lahmbi5678 »

I'm assuming that you used winetricks to install .NET in wine. Which .NET version did you install?

Anyways, you quite probably triggered a bug in wine. Maybe the empty string is a special border case. Please file a bug report and provide a small sample application.
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: .net double misbehaves

Post by DarkShadow44 »

There is a bug report now, see Bug 46842 - C# double.TryParse( String.Empty, out number) succeeds with .NET Framework 4.0 when it should not

@OP: Please link the bug report in the future.
Locked