Bug 10902 - Breakpoints sometimes break at the end of a unit in VS2012
Summary: Breakpoints sometimes break at the end of a unit in VS2012
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 0.x Insider Preview
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Vinicius Jarina
Depends on: 12286
  Show dependency tree
Reported: 2013-03-05 07:54 UTC by John Hair
Modified: 2016-05-10 17:02 UTC (History)
10 users (show)

Is this bug a regression?: ---
Last known good build:

Example project (147.04 KB, application/zip)
2013-06-26 09:24 UTC, John Hair

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Hair 2013-03-05 07:54:49 UTC
Debugging from within VS2012 and put a breakpoint on a line within a specific unit. Run the app, tap a button to run the code, debugger breaks at the end of the unit. Call stack has a huge line number and the wrong method name (the breakpoint is in a different method).
Happens for a specific .cs file, not in others. First noticed it however in a different unit when I had a breakpoint on an inline delegate method:

// Not real code :)
foo.Tapped += delegate
  // Breakpoint in here would break at the end of the unit

Moved the above code into its own method and that works. Not ideal though.
Comment 2 Marek Habersack 2013-03-05 10:35:31 UTC

Can you provide a full test case which demonstrates the issue (a zipped project would be fine)?
Comment 3 John Hair 2013-03-05 10:53:28 UTC
I'll try, I don't want to send the unit that has the issue though. Will see if I can replicated with a Hello World app.
Comment 4 Dominique Louis 2013-06-03 15:17:20 UTC
Possible duplicate of https://bugzilla.xamarin.com/show_bug.cgi?id=12286
Comment 5 John Hair 2013-06-03 23:08:09 UTC
As per the possible duplicate linked above:
I have seen issues with anon delegates too, where the breakpoint fires at the time the delegate is assigned or not at all, but it never in the delegate itself. Workaround, create a method and and assign that as the delegate.
Comment 6 John Hair 2013-06-26 09:24:37 UTC
Created attachment 4206 [details]
Example project

Got an example that behaves badly when debugging and stepping through code.

Load the solution in VS2012.
Put a breakpoint on line 46 in MyViewController.cs, run the example, tap the button.
F10 all the way through the for each, it will loop 4 times. Keep F10 and you will see the current break line move beyond the end of the file, F10 again and it is back, F10 again off the end of the file etc etc.