Bug 21232 - Debugger showing variables as null
Summary: Debugger showing variables as null
Status: RESOLVED DUPLICATE of bug 25358
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger (show other bugs)
Version: 5.1
Hardware: Macintosh Mac OS
: High normal
Target Milestone: master
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2014-07-10 09:21 UTC by Paul Johnson
Modified: 2015-01-07 00:40 UTC (History)
4 users (show)

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


Attachments
Video showing the bug in action (260.20 KB, application/zip)
2014-07-11 07:05 UTC, Paul Johnson
Details

Description Paul Johnson 2014-07-10 09:21:54 UTC
I have a class defined outside of an if condition. Call it outsideClass for this. The class is populated with data (doesn't matter what the class is)

If I have

if (foo)
{
  // something
}
else
{
  var insideClass = outsideClass;
  insideClass.foo = 10;
  insideClass.bar = "20";
  Console.WriteLine("foo = {0}, bar = {1}", foo, bar);
}

the code in else will compile and execute fine, however, if you try to inspect the values for insideClass, insideClass reports as being null.

The same null is seen if you explicitly create an instance of outsideClass type and assign that to the outside class and operate on that new instance viz

else
{
  var insideClass = outsideClassDef();
  insideClass = outsideClass;
  ...
}

Using XS 5.1.1.19
Comment 1 Ram Chandra 2014-07-11 06:48:17 UTC
I tried this issue but I am unable to reproduce this issue

Steps I followed:

1. Open a console application on XS.
2.  Write the following code on "Program.cs" 

    class Demo
    {
        public static void Main()
        {
            outsideClass oc = new outsideClass();
            oc.CreateObjectOfNestedClass();
                       
        }
    }

    class outsideClass
    {
        public int foo { get; set; }
        public string bar { get; set; }
                
        public void CreateObjectOfNestedClass()
        {

            if (false)
            {
                // something
            }
            else
            {
                var insideClass = new outsideClass();
                insideClass.foo = 10;
                insideClass.bar = "20";
                Console.WriteLine("foo = {0}, bar = {1}", insideClass.foo, insideClass.bar);
            }
        }
    }

When I debug my application I observed that the value of insideClass is not null. It contains two property "foo" and "bar".

Screencast: http://www.screencast.com/t/zvDRlJPKG

Please let me know if I am missing anything?

Environment Info:

Mac OS X 10.9.3
Xamarin Studio: 5.1.2 (build 0)
Build Information 

Release ID: 501020000
Git revision: 4574b1e5cf09f2e95e486c259bd9267a68c77cb3
Build date: 2014-07-02 20:50:40-04
Xamarin addins: fdea6fe3e36cda39291b39c81133e409c6d6f092
Comment 2 Paul Johnson 2014-07-11 07:05:31 UTC
Created attachment 7335 [details]
Video showing the bug in action
Comment 3 Ram Chandra 2014-07-11 07:38:39 UTC
Thanks Pual

I have seen your video, but nothing is clear in video. Its totally blur, I have tried using flv player and vlc player, but I am not able to understand what is happening in video. 

Screencast : http://www.screencast.com/t/rTQCEiuoE

Can we please have a clear video or test sample to demonstrate the issue?
Comment 4 Paul Johnson 2014-07-11 08:43:52 UTC
http://screencast.com/t/ijuIDqTq0YP

Hope that makes it clearer.

mb is clearly instantiated at the start of the else block and then assigned to currentMob. If the instance had not been created, then the app would have fallen over at this point. As it is accepting currentMob, I can only conclude that the debugger is not playing ball
Comment 5 David Karlaš 2015-01-07 00:40:08 UTC
This is mcs bug

*** This bug has been marked as a duplicate of bug 25358 ***

Note You need to log in before you can comment on or make changes to this bug.