Problem
Consider the following procedure:
DataTable go() {
return someTableAdapter.getSomeData();
}
Is it possible to analyze the returned value when I create a breakpoint in this function? In an.aspx page, go() is directly linked to a datagrid.
Using a temporary variable is the sole option to inspect the returned datatable. That, however, is inconvenient. Isn’t there a different option?
Asked by doekman
Solution #1
I’m not aware of any. It’s worth noting that if you do add a variable, the compiler will remove it in release builds anyhow…
This feature has now been included in VS2013. The return values are visible in the autos windows, and you can use $ReturnValue in the watch/immediate window.
Because the value can only be viewed after the method returns, the simplest approach to get it is to set a breakpoint on the function call and step over it (F10).
Update for Visual Studio 2015: bummer! Unfortunately, it does not appear to be included in Visual Studio 2015. (devenv v14) VS2017 has been updated: it is now available. (v15 devenv)
Answered by Marc Gravell
Solution #2
According to the customer feedback site, this can be done in Visual Studio 2013 with CLR 4.5.1. In prior versions of C#, it was not available.
(VB.NET was supported in Visual Studio 2008 and prior.) C/C++ programmers have always had access to it.)
Answered by Alex Angas
Solution #3
I believe that viewing the return value of a method before stepping out of it, as well as the return values of methods I’ve just stepped over, is a really valuable feature. It was built as part of “OzCode,” a commercial extension for Visual Studio.
As a type of HUD-display, you can observe method return values immediately on the code editor with it:
Please watch this video for further details.
Answered by Omer Raviv
Solution #4
According to Microsoft, managed code cannot be used to achieve this reliably. They are aware of the issue and are trying to resolve it:
Answered by Dan Solovay
Solution #5
In terms of Visual Studio 2015:
According to Marc Gravell’s current accepted answer:
This functionality does not work in Visual Studio 2015, according to that answer. This isn’t totally correct. There is a comment on Examine return values of method calls that says:
Visual Studio 2015 Enterprise was used to test this:
Answered by PascalK
Post is based on https://stackoverflow.com/questions/268048/can-i-find-out-the-return-value-before-returning-while-debugging-in-visual-studi