Welcome to MSDN Blogs Sign in | Join | Help

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
Published Monday, January 21, 2008 12:25 PM by Sree_c

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Monday, January 21, 2008 4:10 PM by Dave

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?

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Monday, January 21, 2008 4:39 PM by Sree_c

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.

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Monday, January 21, 2008 5:44 PM by Eric

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...

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Monday, January 21, 2008 7:09 PM by onovotny

How about allowing Edit-n-Continue in anonymous methods? :)

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Tuesday, January 22, 2008 5:25 AM by Eamon Nerbonne

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.

# VS2008 SP1?

Tuesday, January 22, 2008 7:19 AM by Righthand blogs

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

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Wednesday, January 23, 2008 3:54 PM by Sree_c

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

# C# Debugging Improvements for VS 2008 SP1- Part 1

Thursday, January 24, 2008 12:04 PM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Saturday, January 26, 2008 6:51 PM by Kornel Lehocz

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.

# re: C# Debugging Improvements for VS 2008 SP1- Part 1

Sunday, January 27, 2008 1:54 AM by Kornel Lehocz

I just found the Enable unmanaged code debugging option. :) So ignore my last silly post.

# Community Convergence XL

Tuesday, January 29, 2008 6:32 PM by Charlie Calvert's Community Blog

Welcome to the fortieth issue of Community Convergence. This week we have two new releases of note: We

# VS2008 SP1?

Wednesday, February 06, 2008 4:23 PM by MihaM

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

# VS2008 SP1?

Wednesday, February 06, 2008 4:53 PM by Zunanji viri

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

# Interesting Finds: 2008.01.22

Monday, March 03, 2008 8:47 PM by gOODiDEA

.NET: C#DebuggingImprovementsforVS2008SP1-Part1

FreeUtility:Web.ConfigEditorwitha...

# re: C++ Debugging Improvements for VS 2008 SP1- Part 1

Monday, March 17, 2008 10:59 AM by Art Fenerty

Ive found c++ debugging quite often wrong. The debugger is showing the wrong address and variable state. For example the watch window will show.

bool  m_Animate  true

when breakpointed on the last line..

m_Animate = false;

bool test = m_Animate

 test will show false, debugger will be pointing several bytes ahead in adress and report m_Animate is true.. havent yet tracked it down..

Art

# Edit/Continue Anonymous delegates, generics and 64-bit

Thursday, November 20, 2008 2:57 AM by Russell Hind

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

# Roadshow Recap (Including Some Answers!)

Thursday, March 26, 2009 2:35 PM by Jim O'Neil's Blog

On Monday, Chris , Bob , and I wrapped up the latest edition of the Northeast Roadshow in Waltham. 

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker