Partager via


C# Debugging Improvements for VS 2008 SP1- Part 1

Overview

Over the past few months I have been busy closing VS 2008 and working on some fixes for SP1. We have enabled some key debugging scenarios in C# in VS 2008 SP1, they include support for 

  1. Range Variables in Queries &
  2. Anonymous Types
  3. Generic Type arguments

Covering all of them was making the post long so i am going to discuss Range variables this time and continue on with the other 2 in the next post.

Range variables

Range variables are the variables defined and used in a query. Currently they have a limitation in that they are not recognized as "true" local variables when stopped/stepping though a query. And since queries are one of the newest constructs in C#, are a prime candidate for SP1.

Range variables cannot currently be inspected in the watch window or in data tips(hover over them), quick watch and immediate. They can only be seen in the locals window,  but the display shows the internal transparent identifier created for the query. This leaves the variable of interest to the user nested and difficult to understand and use.  This happens as long as the user adds

1. A second from,

int[] ints = new int[] { 1, 2, 3, 45, 56 };

var q = from i in ints
            from k in ints
            where i > k      //add BP here
            select i + k;

clip_image002

2. A join or

image

3. A let clause to their query,

image

Seeing these simple examples it is not hard to imagine the debugging state when stopped in queries that use many of these in combination.

image

Here "Hover over" does not work, can't add anything to watch, the transparent identifier gets larger and the lvl of nesting makes it very hard to find the range variables your looking for.

SP1 Changes

All of these issues are now fixed in SP1 and the user has the full set of debugging tools for him to help inspect and evaluate the current state when stopped at a break-point. using the same example

image

Conclusion

In concluding this article, As always I am very interested in

  1. Any others pain points you have discovered while debugging or
  2. Things are are hard to debug.
  3. Things that would be nice to inspect etc.

Looking forward to your feedback. Cheers

kick it on DotNetKicks.com

Comments

  • Anonymous
    January 21, 2008
    You mention a VS2008 SP1, and yet the product is not that long released.  It took what felt like years to get to a SP1 for VS2005 - what is the SP1 released schedule like for VS2008?

  • Anonymous
    January 21, 2008
    VS2005 also took like 3+ years to get done, compared to the 18 month cycle for VS2008. And Yes it's a part of the more agile release cycle that VS will be following going forward. I don't have a good date to tell as to when its done, but it might be sometime this year. Check out Soma's blog he might have more on this soon.

  • Anonymous
    January 21, 2008
    This just seems cruel - discussing the cool features of an upcoming service patch and then giving an 11 month (maybe!) window of when we will get it...

  • Anonymous
    January 21, 2008
    How about allowing Edit-n-Continue in anonymous methods? :)

  • Anonymous
    January 21, 2008
    I second edit and continue in methods containing anonymous delegates (and of course in the anonymous delegates themselves too). Also, it's not possible to use lambda functions in the immediate window or any of the other debugger windows.  This would be extremely handy - for example, LINQ queries are very well suited to drilling down through data structures to find sources of trouble. I'd be extremely pleased to find support for debug-time LINQ and other code-generation features (write a method just to analyze the state as it is now).  If access to local variables complicates matters, I would much prefer being able to write a LINQ query and/or debug-time dynamic method which can only access member variables than not be able to use these features at all.

  • Anonymous
    January 21, 2008
    I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  • Anonymous
    January 23, 2008
    Interesting... i can totally see how lambdas and queries can be used to inspect interesting elements of a big data structure. Adding these features has been challenging mainly due to the fact that we can’t generate types at runtime and the lambda is rewritten to a display class. We could restrict the lambda to variables that are already hoisted but that complicates the user model.   I am personally looking forward to implement many of these for VS10,  Though there are a few things that need to be figured out. Enc is another area we will be revisting for VS10

  • Anonymous
    January 24, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    January 26, 2008
    Please fix debugging of managed/native mixed dll-s. I don't know if this is a general bug or if it only doesn't work here. But it doesn't work at all. Breakpoints set in native code are just ignored. (VS 2008 Pro, Windows XP SP2) And please also improve C++ debugging.

  • Anonymous
    January 26, 2008
    I just found the Enable unmanaged code debugging option. :) So ignore my last silly post.

  • Anonymous
    January 29, 2008
    Welcome to the fortieth issue of Community Convergence. This week we have two new releases of note: We

  • Anonymous
    February 06, 2008
    I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  • Anonymous
    February 06, 2008
    I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  • Anonymous
    March 03, 2008
    .NET: C#DebuggingImprovementsforVS2008SP1-Part1 FreeUtility:Web.ConfigEditorwitha...

  • Anonymous
    March 17, 2008
    The comment has been removed

  • Anonymous
    November 19, 2008
    As requested above, we really could use edit/continue debugging of anonymous delegates.  Currently we don't use anonymous delegates because some of our simulation/test runs can take hours and we can make heavy use of edit/continue which is not supported. Edit/continue of generics would also be very useful and we're just moving to Vista 64 and miss edit/continue on this as well. It would be useful to have a standard feature set across all platforms and language features. Thanks Russell

  • Anonymous
    March 26, 2009
    On Monday, Chris , Bob , and I wrapped up the latest edition of the Northeast Roadshow in Waltham.