Bug 5664 - Watch Window displays incorrectly Nullable<> fields' values
Summary: Watch Window displays incorrectly Nullable<> fields' values
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-06-15 03:13 UTC by Plamen Ivanov
Modified: 2012-06-24 15:29 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Repro project (425.82 KB, application/x-zip-compressed)
2012-06-15 03:13 UTC, Plamen Ivanov

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Plamen Ivanov 2012-06-15 03:13:32 UTC
Created attachment 2065 [details]
Repro project

Windows 7 x86 SP1
Microsoft .NET Framework 4.0
Gtk# for .NET 2.12.20
Java SE JDK 6 Update 32
Android SDK Tools r18
MonoDevelop 3.0.2
Mono for Android 4.2.2

While evaluating communication with WCF service I found, that nullable fields of the objects are displayed incorrectly as not having values, while actually they do have values.

In the repro project, put breakpoint after reading of the fields into local variables. You can see, that in local variables values are read correctly. But if you put some nullable field of the object into Watch window, it is displayed as empty and if expanded, shows HasValue -> false and Value -> exception.

Bug exists for int, double and DateTime nullable values - only string is displayed correcty.

Note, that similar "half-bug" exists in MonoDevelop 3.0.2 for MacOS X. In Watch window it displays int value as empty (i.e. "{}"), but if expanded shows correctly HasValue -> true and Value -> actual value. On MacOS X this behavior exists only for int nullable value - double and DateTime nullable values are displayed correctly.
Comment 1 Jeffrey Stedfast 2012-06-15 13:24:27 UTC
This appears to be fixed in MonoDevelop

I can repro the Mac case in 3.0.2 on Mac, but not with
Comment 2 Plamen Ivanov 2012-06-15 14:00:42 UTC
I did not install MonoDevelop because it is still in Beta and I use machine for production development.

Can you confirm that the bug is resolved also in MonoDevelop for Windows?
Comment 3 Jeffrey Stedfast 2012-06-15 17:33:33 UTC
yep, works on windows too
Comment 4 Plamen Ivanov 2012-06-19 11:41:27 UTC
Today I upgraded to:

Windows 7 x86 SP1
Microsoft .NET Framework 4.0
Gtk# for .NET 2.12.20
Java SE JDK 6 Update 33
Android SDK Tools r18
Mono for Android 4.2.3

I can confirm that bugs in Watch window exists in MonoDevelop for MacOS X and for Windows exactly the same way they are described in initial bug report.
Comment 5 Jeffrey Stedfast 2012-06-19 12:53:28 UTC
Where are you setting the breakpoint? before or after the values are set?

The only way I can reproduce this bug is if the values haven't been initialized yet.
Comment 6 Plamen Ivanov 2012-06-19 15:18:04 UTC
I set the breakpoint on "}" immediately after last assignment:

string StringValue = to.StringValue;

When execution break, you can see that local variables:

Nullable<int> IntValue
Nullable<double> DoubleValue
Nullable<DateTime> DateTimeValue
string StringValue

are as expected, i.e. not empty. At the same time, if you put:


in the Watch window and expand it, it shows empty member properties.
Comment 7 Jeffrey Stedfast 2012-06-19 15:30:16 UTC
oh, I was setting watchpoints on "to.IntValue", "to.DoubleValue", etc

If you do that, the values are correct.

I'll see if I can figure out why "IntValue" is wrong when expanded from "to"
Comment 8 Jeffrey Stedfast 2012-06-19 16:10:45 UTC
looks like the Nullable object reference we get back from the runtime has a HasValue value of "false", even though the Value field has the right value (1).

Zoltan: could you take a look at this?

Here's a simpler test case:

using System;
using System.Collections.Generic;

namespace TestCase {
	class Program {
		static void Main (string[] args)
			TestObject to = new TestObject() { IntValue = 1/*, DoubleValue = 2.0, DateTimeValue = DateTime.Now, StringValue = "ABC"*/ };

			Nullable<int> IntValue = to.IntValue;
			//Nullable<double> DoubleValue = to.DoubleValue;
			//Nullable<DateTime> DateTimeValue = to.DateTimeValue;
			//string StringValue = to.StringValue;

			Console.WriteLine ("break here");

	public class TestObject
		public Nullable<int> IntValue { get; set; }
		//public Nullable<double> DoubleValue { get; set; }
		//public Nullable<DateTime> DateTimeValue { get; set; }
		//public string StringValue { get; set; }
Comment 9 Zoltan Varga 2012-06-19 16:42:38 UTC
This was fixed in mono master, but the changes are not in 2.10 or mobile-master.
Comment 10 Zoltan Varga 2012-06-19 16:56:38 UTC
Should now be fixed in 2.10/mobile-master.
Comment 11 Jeffrey Stedfast 2012-06-20 11:49:23 UTC
awesome, thanks Zoltan!
Comment 12 Zoltan Varga 2012-06-24 15:29:26 UTC