2

Please, observe:

enter image description here

It works neither in the Immediate Window nor when setting a conditional breakpoint.

Can anyone explain what am I doing wrong?

EDIT 1

Use the legacy C# and VB expression evaluators is unchecked.

However, Use managed compatibility mode is checked. But I remember turning it on in order to work around a bug in the VS 2015 debugger. I need some more time to get the details of the bug.

EDIT 2

The watch window is dysfunctional with Use managed compatibility mode unchecked in VS 2015. For example: enter image description here

Note, that this is the Debug mode, not Release. I remember having a lot of issues with inspecting the state while debugging and that the prevailing recommendation was to turn on Use managed compatibility mode.

Unfortunately, I cannot move to VS2017, since our code base still has some Silverlight code.

Of course, this strange behaviour goes away once I am in the compatibility mode.

mark
  • 59,016
  • 79
  • 296
  • 580
  • 1
    It likely just doesn't support it. Not unusual, LINQ isn't support in the Immediate window either – Liam Jan 22 '18 at 15:27
  • Are you sure that already worked in VS2015? I don't remember when, but MS did overhaul this part of VS to get such stuff working and I'm not sure the new versions are in VS2015 or VS2017... – Christoph Fink Jan 22 '18 at 15:27
  • I am totally unsure if it worked before. I just recently started using these C# 6 goodies and I just naively assumed they were supported in the IDE. – mark Jan 22 '18 at 15:28
  • I am almost 100% certain lambdas are working in watch window and linq too, still using VS2015. See [this](https://stackoverflow.com/q/36559399/1997232). – Sinatr Jan 22 '18 at 15:42
  • @Liam LINQ works fine for me in the IW of 2015. In previous editions that was not the case. – Kenneth K. Jan 22 '18 at 15:44
  • Possible duplicate of [lambda expressions in immediate window for VS2015](https://stackoverflow.com/questions/36559399/lambda-expressions-in-immediate-window-for-vs2015) – Christoph Fink Jan 22 '18 at 15:48

1 Answers1

2

It should work - I just tried it in VS 2015 (v14.0.25431.01 Update 3), and the null conditional syntax worked fine in the watch window.

Make sure you don't have the "Use the legacy C# and VB expression evaluators" config setting checked (under Options -> Debugging).

RobSiklos
  • 8,348
  • 5
  • 47
  • 77