4

I'm trying to debug lambda expressions with Visual Studio 2015 while in debug mode on an Android device. If I put

this.customerList.Where(p => p.LastName == "Doe").ToList()

in the Watch or Immediate Window I get

Expression not supported.

I'm doing this after the debugger stopped at the breakpoint. If I don't use the breakpoint I get

The expression cannot be evaluated while in run mode.

What I'm doing wrong?

The options stated in lambda expressions in immediate window for VS2015 are grayed out and not ticked, while in debug mode.

Edit

I tried the example code from Tatranskymedved with the same result:

Debugging lambda expression not possible

My guess is that debugging lambda expression is not possible with Xamarin. I tried it on device and on simulator and both are showing the same result. Another possibility would be that I have to change some debugger settings. Here I tried to disable Use Fast Deployment (debug mode only) and Use Shared Runtime without success.

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417
  • Whats the problem of `Expression not supported.`? What did you expect? (or not). It's probably because the `this.customerList.Where(p => p.LastName == "Doe")` returns an `IQueryable<>` – Jeroen van Langen Mar 23 '17 at 12:13
  • What exactly is `customerList`? – juharr Mar 23 '17 at 12:14
  • 1
    @JeroenvanLangen: I expect to get an object, which satisfy the condition, where I could dig in deeper to inspect some variables. Now I have 300+ entries in the list and I don't want to click through all of this to inspect my object. An alternative solution would be write the query directly in the code, recompile, debug and inspect. The above mentioned feature would come in handy. Shouldn't `ToList()` or `ToArray()` handle this? – testing Mar 23 '17 at 12:17
  • @juharr: Simplified said a `List`, where `Person` inherits finally from `INotifyPropertyChanged`. – testing Mar 23 '17 at 12:20
  • 1
    @testing I just tried it myself, watching both `list.Where()` and `list.Where().ToList()` worked well. Could You please add definition of Your `Customer` class? http://imgur.com/a/4iDkA – Tatranskymedved Mar 23 '17 at 13:39
  • Also works in immediate window. When i started debugging, watch shows me the same message as to You, but once I clicked on the "ring arrow", it evaluates the query and gave me the results. – Tatranskymedved Mar 23 '17 at 13:49
  • 1
    @Tatranskymedved: Thanks for your response. There is no "ring arrow" in my case. On which machine have you tested your code? I'm running directly on an Android tablet and I can imagine that this can cause the issue or I have to change some debugger settings. I could provide you the full object, but that would be very big. I think I'll try a very simple example project and then I update my question with the code of this example. – testing Mar 23 '17 at 13:59
  • So that might be the issue. I run the code on normal laptop with win10. – Tatranskymedved Mar 23 '17 at 14:01
  • 1
    I just tried on Xamarin myself, same behavior as You have. – Tatranskymedved Mar 23 '17 at 14:31
  • @Tatranskymedved: In my screenshot I now noted that he writes at the bottom *This item does not support previewing*. Is this related? – testing Mar 23 '17 at 14:36
  • I have not found any post/other question on SO (nobody works with that.. muhehe). Downgrade target .NET version (for normal app) and it still works well. Probably this sort of debugging is not supported on Xa. Got no clue. – Tatranskymedved Mar 23 '17 at 14:56
  • @Tatranskymedved: Thanks for your confirmation, that this also doesn't work on your side. Do you want to post this as an answer? I find this funny, when some pro user downvote and vote for closing this question, while not really understanding the issue (but think that this is only an easy question like a typo) ... – testing Mar 23 '17 at 15:00

1 Answers1

5

After running several tests (no post/article on this topic found as a reference), I came to verdict that debugging of Lambda expressions does not work on Xamarin with Xamarin debugger.

Same code/expression does normally work on standard application:

a

This seems to be unrelated to version of .NET, as downgrading to version 4.0 (on Console app), still provide same debug results.

I have noted that in properties of Android project, there is an option called "debugger" and values to choose from: Xamarin, Microsoft Standard debug of Console app is most likely with the Microsoft one - which might have full support of debugging the Lambda expression.

Tatranskymedved
  • 4,194
  • 3
  • 21
  • 47