0

I've encountered an odd behaviour with mtouch; I know that AOT can fail in particular situations, but I think this issue is a little different.

Here's some code:

public class TTableCell
{
}

public class TTableElement<T>
    where T: TTableElement<T>
{
    public void SetProperty<TV> (ref TV backingStorage, string propName, TV value)
    {
        backingStorage = value;
    }
}

public class TAbstractTableItem<TC> : TTableElement<TAbstractTableItem<TC>>
    where TC : TTableCell
{
    public TAbstractTableItem ()
    {
    }

    string _string;
    bool _bool;

    public void DoException ()
    {
        SetProperty (ref _string, "String", "Bla bla");
        SetProperty (ref _bool, "Boolean", false);
    }
}

Now, if do the following somewhere else:

TTableItem<TTableCell> item = new TTableItem<TTableCell> ();
item.DoException ();

I get the exception:

Unhandled managed exception: Attempting to JIT compile method 'TouchSandbox.TTableElement`1<TouchSandbox.TAbstractTableItem`1<TouchSandbox.TTableCell>>:SetProperty<bool> (bool&,string,bool)'

Now, notice that the exception is thrown only for the boolean version of SetProperty<T>, not the string one. In my project I use a variety of types for the method (custom types too) and this issue happens only with bool.

Can anyone help me with this, please?

Thanks

Sergio

P.S. Obviously this issue is present into the iDevice only (not the simulator)

UPDATE

Ok, after a little search into xamarin's bugzilla I found a ticket (actually a bit old!) that highlights a lack in mtouch AOT: Bug 2096. Sadly, it seems they don't fix yet!!!

Atropo
  • 125
  • 8

1 Answers1

2

There seems to be a problem with generic methods inside generic classes.

I've also tried the test case with the 6.3 beta (which might fix this problem since many things have improved in exactly this area), but it crashes instead of throwing an exception (bug filed - you can CC yourself to be updated when it's fixed).

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • yep, thanks... actually I've tried with other value-types (int, float, DateTime) and seems it is related to them. – Atropo Apr 24 '13 at 12:27