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!!!