0

The referred duplicate is a) not VS 2015 specific, b) there is an explicit comment there for the accepted answer:

unfortunately, it doesn't appear to be in VS2015 (devenv v14)

so I am looking for how to do this in VS 2015?

--- Original question was: ----

While debugging in VS 2015 many times I would like to know the actual value what a method returns. (like return <expression>;)

In scenarios often I can not figure out better, than (stop), modify the source code and write

var result = <expression>;
return result; // and place a breakpoint here, and "watch" the result variable.

Scenarios like:

  • The <expression> is complex like LINQ with many embedded functions, and potentially evaluating it may have side effects, or simply the iterator can not be iterated multiple times
  • ...or... The debugger hangs when trying to evaluate <expression> interactively in watch window
  • At caller side the context is not as simple like x = y.MyMethod(), so I can simply see the return value there (instead evaluating of MyMethod return value)

I just wondering is there a built in way what I am missing, and placing a breakpoint (see below) and somehow know the actual (already evaluated) real return value?

    //...
    return <expression>;
} // place a beakpoint here and see what is the actual eveluated return value
// Maybe I am wrong, but I think it must be an point in time when the actual
// return value is already evaluated runtime so it is not an extreme idea to 
//allow to "watch" it for the developer.
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
  • Why not inspect the value via QuickWatch? Alternativly simply have a look within the calling code. – MakePeaceGreatAgain Mar 17 '16 at 08:17
  • because "The is complex like LINQ with many embedded functions, and potentially evaluating it may have side effects, or simply the iterator can not be iterated multiple times ...or... The debugger hangs when trying to evaluate interactively in watch window" (or QuickWatch window) and for alternatively: "At caller side the context is not as simple like x = y.MyMethod(), so I can simply see the return value there (instead evaluating of MyMethod return value)" – g.pickardou Mar 17 '16 at 08:18
  • I don't think it's possible because Linq works on IEnumerable which uses deferred execution – Alexander Derck Mar 17 '16 at 08:21
  • @AlexanderDerck: Good point, however the question is more general and not LINQ specific, any other (without LINQ) may have side effects. LINQ was just a sample, or just replace my sample added .ToList() on the ending, or suppose some single result LINQ like .FirstOrDefault() or .Count() – g.pickardou Mar 17 '16 at 08:24

0 Answers0