Add a 'return' pseudo variable to the Visual Studio debugger for .NET code - by Alex Angas

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 597933 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 9/14/2010 10:21:40 PM
Access Restriction Public


Currently there is nowhere in the debugger to find out the value returned from a method, unless it is assigned to a temporary variable first. A special 'return' pseudo variable is desired to show (and preferably change) this value. This already exists for C/C++ developers as described in point 2 here:

More people requesting this at Stack Overflow:

Related to this logged issue on Connect:
Sign in to post a comment.
Posted by Anders on 11/7/2012 at 1:17 AM
The fact that there may be extreme cases where the returned value is not be easy to extract, is no argument for skipping it in all situations.

Just like the previous writer mentions, the fundamental case is about being able to watch the value that is being returned from the method that you are currently debugging.

In the extreme cases, where the return value is uncertain, simply display a "n/a"-message...
Posted by Johan H. Nilsson on 9/21/2012 at 12:40 AM
"In managed code, it’s a lot trickier to determine what the return value of a function you’ve stepped over."

For God's sake, forget about the advanced feature of displaying the return value functions that are stepped over. This issue is about displaying the return value of the function the debugger is within.

int foo(int a)
return a+a*2+123;
} <-- when debugger is standing on this row add a 'result' variable to the locals window.

The lack of this feature make programmers change their coding style to:

int foo(int a)
int result = a+a*2+123;
return result;

or even worse, clean looking code like:

bool IsWithinTolerance(double value)
return min <= value && value <= max;

is replaced with the horrific:

bool IsWithinTolerance(double value)
if (min <= value && value <= max)
     return true;
     return false;

For Satan's sake, the debugger should not force programmers to code in a certain way.
Posted by Microsoft on 2/15/2012 at 9:23 AM
For those out there who have experience debugging native C++ or VB6 code, you may have used a feature where function return values are provided for you in the Autos window. Unfortunately, this functionality does not exist for managed code. While you can work around this issue by assigning the return values to a local variable, this is not as convenient because it requires modifying your code.
In managed code, it’s a lot trickier to determine what the return value of a function you’ve stepped over. We realized that we couldn’t do the right thing consistently here and so we removed the feature rather than give you incorrect results in the debugger. However, we want to bring this back for you and our CLR and Debugger teams are looking at a number potential solutions to this problem. Unfortunately this is will not be part of Visual Studio 11.
Posted by Shimmy Weitzhandler on 2/11/2012 at 9:01 PM
Very compelling!
Posted by Manitra Andriamitondra on 2/7/2012 at 8:30 AM

Just a small comment to emphase the fact that people really needs this feature :)

Posted by Omer Raviv on 12/13/2011 at 12:30 PM
I implemented a feature that lets you see the return value before stepping out of the method part of a commercial extension to Visual Studio called "BugAid", currently in beta. It also seeing the return value of the method calls you stepped over, and it also when you're returning the result of a linq query.

Please see my blog post on the subject: and try it out for yourself!
Posted by Brian Seekford on 9/29/2011 at 9:46 AM
This would be nice to have. Since my returns migh have a linq query in them. Would like to know what is being returned without having to add temp vars.
Posted by Steve Westlake on 6/14/2011 at 3:06 AM
This is one of the best features of VS for C++. It becoming especially important in C# with the expansion of techniques like functional programming where less use is made of local variables.
Posted by Alex Angas on 10/15/2010 at 6:02 PM
Hello VS Debugger Team,

Thank you for your response, but with respect it was available for Visual Basic .NET under Visual Studio 2008. See reference: "You can set the breakpoint at the End Function line and hover the cursor over the function name." Please also see screenshot linked from that post:

So it *used* to be possible for .NET code. Could we please have it return for VB.NET and introduced for C# as well?

Thanks and regards.
Posted by Microsoft on 10/15/2010 at 5:48 PM

This feature is available in VB 6, VBA, and C++ but unfortunately is not currently possible for .NET code. We will consider this feature for future releases of Visual Studio.

Visual Studio Debugger Team
Posted by Simon Lampen on 10/7/2010 at 3:54 PM
This has also been available in VB (.net, VB and VBA) as the name of the function appears as the variable that stores the return value. It would be great to have this in c# so you have read-write access to the variable before the function completely returns.