While debugging our Xamarin.Android project, we're finding that any breakpoints that we place within Async methods are not being hit.
The architecture is a Xamarin.Android application project and a Xamarin.Android "Core" class library project.
Any thoughts? Is this a Xamarin bug or something that we're just not doing properly?
Posts
It seems that file linking in Debug mode = no bueno. Setting linking to None fixed the issue. Of course, Release builds need the linking - but we're not debugging those anyway.
Still, sounds like a bug to me.
you shoud never link in debug mode. It is not a bug.
Is this somewhere documented?
Linking means optimizing things around (removing unused code, inlining methods, combining variables, ..). This is described in the compilation process in Xamarin docs, and in all compilers since 30 years.
When optimizing things, debugger won't work correctly anymore as they are not smart enough to understand these optimisations. This is because the linker won't create a smart enough debug map file for it. Maybe one day...
The Linking setting that is preventing the debugger from hitting breakpoints in our library project is "SDK Assemblies Only". Given that, this is a valid use case for debugging and linking.
I might be wrong but I think that Xamarin linking is about code elimination, not optimization. Besides even in optimization mode debugging should still work in certain limits of course.
confirmed bug:
https://bugzilla.xamarin.com/show_bug.cgi?id=17512
Guys, this is not a bug. Don't be stubborn. You want to debug, you don't link. Dot.
If linking is completly disabled, and if the breakpoint is not hit (which is the case in async delegates or task based actions, even in "normal" C# app), then it is a bug. The bug is probably a limitation more than a bug, as it also happens in normal C# apps, even in test projects if using async/await keywords instead of .Wait() or .Result.
I agree with you it should break. Now try to throw in the same place. The Task Unhandled Exception breakpoint is not hit. This ... is a bug.
We are not linking the assemblies we are trying to debug. The linking setting for that is "All Assemblies" which I have made clear we are not using. The Linking setting in question "SDK Assemblies Only" should exclude linking assemblies in our project so the "don't link if you want to debug" argument is invalid.
Regardless, Xamarin obviously agrees as they have confirmed this as a bug per the bug report I submitted.
@softlion Wait, what?
We have just faced the issue. Linking is off, but async methods get transformed into somehting different based on CompileServices and I can see strange records in Call Stack, but can't set breakpoint.
Is this still an issue?
Still an issue for me.
Xamarin Studio. Mac project. PCL library. Async methods
Still an issue, for me as well. Nothing I've tried seems to work.
Yes it has never been fixed.
Breakpoints are also not being hit in a pcl method called from another pcl lib called from the android app. Not easy to debug ...
This is still broken. I've turned off linking, verified that the method is being called and it still isn't working. So I had to debug old school. Output to console and output values. Really tedious.
I'm hitting this problem today too, also in a PCL. Very frustrating since C# really likes to push the async/await pattern.
Fellas, in a couple of other threads, @FredyWenger posted a solution that works for me too. Rather than "step into" (F11) to advance a line in your code during debug, hit "step over" (or the F10 key). It will actually behave like "step into" by going a single line at a time.
did you try to add:
[assembly: Dependency(typeof(your class with await method in it))]
before namespace?
I am also facing this problem, How can we fix this problem ,Is this is a bug of Xamarin
I think I just hit this issue. Every other method, breakpoints work. If I convert the method from async void to void, it works. But async void (this is an event handler), it says symbols aren't loaded for the document.