Bug 20675 - Subclassed UITableView with generic class fails on device when user taps on top of the screen (scroll to top gesture)
Summary: Subclassed UITableView with generic class fails on device when user taps on t...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.2.3
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
: 21894 ()
Depends on:
Blocks:
 
Reported: 2014-06-18 06:47 UTC by Oleg
Modified: 2014-08-07 09:28 UTC (History)
6 users (show)

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

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:
Status:
VERIFIED FIXED

Description Oleg 2014-06-18 06:47:37 UTC
Code to reproduce:

public partial class TestTableViewController : UIViewController
{
	public TestTableViewController (IntPtr handle) : base (handle)
	{
	}

	public override void ViewDidLoad ()
	{
		base.ViewDidLoad ();

		var tableView = new MyTableView<object>(new RectangleF(0, 0, View.Frame.Width, View.Frame.Height));
		View.AddSubview (tableView);
	}

	public class MyTableView<T> : UITableView
	{
		public MyTableView (RectangleF frame) : base (frame)
		{
		}			
	}
}

When user taps on top of the screen (scroll to top gesture) application crashes with exception (on device only, on simulator works fine):

Jun 18 14:42:08 Olegs-iPhone TestTable[768] <Warning>: Unhandled managed exception: Failed to find the closed generic method 'InvokeConformsToProtocol' on the type 'TestTable.TestTableViewController+MyTableView`1[[System.Object, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'. (MonoTouch.MonoTouchException)
	  at MonoTouch.Registrar.DynamicRegistrar.FindClosedMethod (System.Type closed_type, System.Reflection.MethodBase open_method) [0x00072] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.DynamicRegistrar.cs:615 
	  at MonoTouch.ObjCRuntime.Runtime.GetGenericMethodDirect (IntPtr obj, IntPtr typeptr, IntPtr methodptr, Int32 paramCount, System.IntPtr* paramptr) [0x00035] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Runtime.cs:268 
	  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:GetGenericMethodDirect (intptr,intptr,intptr,int,intptr*)
	  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
	  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 
	  at TestTable.Application.Main (System.String[] args) [0x00008] in /Users/olegs/Projects/TestTable/TestTable/Main.cs:17
Comment 1 Oleg 2014-06-18 06:49:33 UTC
The workaround is to add additional base class for generic class before UITableView:

public partial class TestTableViewController : UIViewController
{
	public TestTableViewController (IntPtr handle) : base (handle)
	{
	}

	public override void ViewDidLoad ()
	{
		base.ViewDidLoad ();

		var tableView = new MyTableView<object>(new RectangleF(0, 0, View.Frame.Width, View.Frame.Height));
		View.AddSubview (tableView);
	}

	public class MyTableView<T> : MyTableViewParent
	{
		public MyTableView (RectangleF frame) : base (frame)
		{
		}			
	}

	public class MyTableViewParent : UITableView
	{
		public MyTableViewParent (RectangleF frame) : base (frame)
		{
		}
	}
}
Comment 2 Sadik Ali 2014-06-18 08:47:29 UTC
I have checked this issue and I am able to reproduce this issue.

Steps to reproduce

1. Open an iPhone "Single View Application" on XS.
2. Paste the following code on ViewDidLoad() method.
         
             var tableView = new MyTableView<object>(new RectangleF(0, 0,
             View.Frame.Width, View.Frame.Height));
             View.AddSubview (tableView);

3. Create a new class in "ViewController" class 
      
           public class MyTableView<T> : UITableView
           {
               public MyTableView (RectangleF frame) : base (frame)
               {
               }            
           }

4. Build and deploy application on device.
5. Tap on the top of screen of device.
5. An Exception will occur.

When I deploy the application on device and tap on the top of screen of device. XS throws "Failed to find the closed generic method" exception. I am not getting this exception on simulator.

Exception detail: https://gist.github.com/saurabh360/dd9932071d968b58e5bc

IDE log: https://gist.github.com/saurabh360/cae97a24670769c0ec3f

Screencast: http://www.screencast.com/t/8gWj0lwDQSOd

Environment Info: 

=== Xamarin Studio ===

Version 5.0.1 (build 3)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.4.0 ((no/63569a7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000205

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.Android ===

Version: 4.12.4 (Trial Edition)
Android SDK: /Users/jatin66/Desktop/Backup/android-sdk-macosx
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Xamarin.iOS ===

Version: 7.2.3.39 (Trial Edition)
Hash: fc6f56b
Branch: 
Build date: 2014-05-19 19:10:29-0400

=== Xamarin.Mac ===

Xamarin.Mac: 1.8.0.8

=== Build Information ===

Release ID: 500010003
Git revision: f94ee866936d25105704eb63728ad5a981eda0a4
Build date: 2014-06-04 12:19:12-04
Xamarin addins: 1a6044e8321ea07e03a56b5381951686c82fed8b

=== Operating System ===

Mac OS X 10.9.2
Comment 4 Rolf Bjarne Kvinge [MSFT] 2014-06-30 18:48:15 UTC
Fixed.

monotouch/master: be6d273851f0007af14897b1bdb85f82d4cde15c
Comment 5 Rolf Bjarne Kvinge [MSFT] 2014-06-30 18:48:30 UTC
QA: unit tests were added.
Comment 6 Ram Chandra 2014-08-05 09:28:43 UTC
I have checked this issue on following builds:

Mac OS X 10.8.4
Xamarin Studio: 5.3 (build 412)
Installation UUID: 449f40dd-b3f1-4028-9a6b-cca0d1a2307d
Runtime:
	Mono 3.6.0 ((no/80b4f74)
	GTK+ 2.24.23 (Raleigh theme)
	Package version: 306000040

Xcode 5.1.1 (5085)
Xamarin.iOS: 7.4.0.87 (Enterprise Edition)
Build Information
Release ID: 503000412
Git revision: 77e042831804079a649ee83092ed36c7c10773a2
Build date: 2014-08-01 06:32:22-04
Xamarin addins: 57e379e6a9454a1c0d97aa3f770e7ae7cc16c522

I have checked this issue with the steps mentioned in "Comment 2" and observed now I am not getting any exception when I tap on top of the screen.

This issue has been fixed. Hence, I am closing this issue.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2014-08-07 09:28:32 UTC
*** Bug 21894 has been marked as a duplicate of this bug. ***