The below example compiles fine in regular Mono 2.10.9:
namespace covarianttest
{
public interface ITest<out T> : IEnumerable<T>
{
}
}
However when I attempt compile it against MonoTouch 6.0.8 I receive this error:
Error CS1961: The covariant type parameter 'T' must be invariantly valid on 'covarianttest.ITest'
So am I to assume that MonoTouch doesn't support extending covariant/contravariant generic interfaces yet? If so what is the recommend workaround for this situation in MonoTouch?
This actually depend on the compiler (and profile/runtime) not the Mono version. IOW some things might work on Mono 2.10 and not with MonoTouch 6.x.
Current versions of MonoTouch ships with the smcs
compiler and a 2.1 based profile (mostly Silverlight and some .NET 4.0 additions).
Newer features, like covariance, requires a full 4.0 compiler (e.g. dmcs
in Mono 2.10 or mcs
in Mono 3.0) and runtime.
Future versions of MonoTouch (likely this spring with alpha/beta in early 2013) will provide a 4.0/4.5 runtime and compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With