[Mono-osx] Overriding DrawRect in a generic class derived from NSView results in "MethodInfo cannot be in a generic type"

Andrew Dove andrew.dove at ni.com
Wed Feb 22 15:22:48 UTC 2012


I have a class for a custom control I am porting from WPF to MonoTouch and 
MonoMac. The class is a generic and I have derived it from NSView like 
this

class NumericControl<TData, TOffset> : NSView
{
        // constructors and initializers etc.

        // draw the control
        public override DrawRect(RectangleF rect)
        {
                // draw something
        }
}

This all works fine in MonoTouch.

When I instantiate the class in the WindowDidLoad of my 
MainWindowController class in MonoMac like this

NumericControl<double, double> numeric1 = new NumericControl<double, 
double>();
Window.ContentView.AddSubview(numeric1);

I get a System.ArgumentException "MethodInfo cannot be in a generic type".

If I derive another non-generic class from the generic and put the 
DrawRect override in there everything works fine.

This seems like a bug in MonoMac or at least a gap in the implementation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20120222/8e6865a0/attachment.html>


More information about the Mono-osx mailing list