When debugging C/C++ (unmanaged?) code in VS, after stepping out of a function, you can see the returned value in the 'autos' window:
alt text http://img156.imageshack.us/img156/6082/cpp.jpg
However, this does not work for C# code:
alt text http://img120.imageshack.us/img120/9350/38617355.jpg
Any suggestion on how to get the return value other than cluttering the code with temporary variables?
It is actually visible. Debug + Other Windows + Registers. Look at the value of EAX (RAX in x64). The value of simple integral types are returned in the EAX register. Long in EDX:EAX. Floating point in STx (XMM00 in x64).
This has been hard to implement, the jitter determines how methods return a value and different jitters will make different choices. Particularly so when the return value type isn't simple, like a struct. If it is large then the jitter will reserve stack space on the calling method and pass a pointer to that space so the called method can copy the return value there. Nevertheless, VS2013 finally made it available, currently available in preview. Visible in the Autos window and by using the $ReturnValue
intrinsic variable in the Immediate window and watch expressions.
Unfortunately cluttering your code with temporary variables in the only way in managed code (C# or VB). The CLR has no support for "managed return values" in the debugger and hence VS does not either.
In C++ this feature is a bit simpler. C++ can just grab the register or stack location of the last return value. It doesn't have to deal with issues like a JITer and garbage collection. Both of which greatly complicate a feature such as this.
If you'd like this feature I strongly encourage you to file a feature request or vote for an existing one on connect
https://connect.microsoft.com/VisualStudio
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With