Bug 3110 - Breakpoints work incorrectly for generic classes
Summary: Breakpoints work incorrectly for generic classes
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: 2.8.6
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2012-01-27 06:04 UTC by Ivan Nikitin
Modified: 2012-01-30 12:38 UTC (History)
4 users (show)

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

A sample project (8.43 KB, application/zip)
2012-01-27 06:05 UTC, Ivan Nikitin

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 or GitHub 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 Ivan Nikitin 2012-01-27 06:04:47 UTC
Breakpoints get fired for a single generic class instance only.

The project attached contains a generic UITextField descendant with a generic property "T SelectedObject". Put a breakpoint on the first line of the property setter, run the project and the breakpoint will be fired just once. However, the Application Output window will show the setter was called twice.
Comment 1 Ivan Nikitin 2012-01-27 06:05:11 UTC
Created attachment 1278 [details]
A sample project
Comment 2 Jeffrey Stedfast 2012-01-27 13:23:48 UTC
I assume you meant 2.8.6 and not 2.8.0 beta 3
Comment 3 Ivan Nikitin 2012-01-28 04:02:30 UTC
Yes, I have I supposed it's the same as 2.8 beta 3 since there is no 2.8.6 version. I'm sorry for misleading you.
Comment 4 Zoltan Varga 2012-01-29 03:12:48 UTC
This is not mt specific:
using System;
using System.Threading;
using System.Net;
using System.IO;

class Foo<T> {
	public T Value {
			get {
				return default(T);
			set {
			Console.WriteLine ("X");
class Tests
	public static void Main () {
		Foo<int> f1 = new Foo<int> ();
		Foo<float> f2 = new Foo<float> ();
		f1.Value = 1;
		f2.Value = 1.0f;
Place a breakpoint at the Console.WriteLine () line. It will only be hit once.
Comment 5 Zoltan Varga 2012-01-29 04:13:58 UTC
So the problem is that the breakpoints get resolved, i.e. removed from pending_bes  when TypeLoad event for Foo<int> is received by md.
There could be multiple solutions:
* Don't remove the bp from pending_bes. This means that the 'Req' field of BreakInfo needs to be a list, since a breakpoint can have multiple requests associated with it.
* Insert a breakpoint into Foo<T>.set_Value () instead. This would require adding a lot of generics stuff into Mono.Debugger.Soft, i.e. IsGenericTypeDefinition, etc. Also, some code needs to be written to map Foo<int>.set_Value () to Foo<T>.set_Value ().
Comment 6 Jeffrey Stedfast 2012-01-30 10:32:20 UTC
Zoltan: yeah, I had kinda already settled on solution #1 on Friday.

I would not be opposed to solution #2, though, but I think #1 wouldn't be too hard to implement.
Comment 7 Jeffrey Stedfast 2012-01-30 12:38:22 UTC
Implemented in git master.