MonoTouch and supporting common interface options

The following example compiles in regular Mono 2.10.9:

namespace covarianttest { public interface ITest<out T> : IEnumerable<T> { } } 

However, when I try to compile it with MonoTouch 6.0.8, I get this error:

Error CS1961: covariance type parameter "T" must be invariantly valid on "covarianttest.ITest"

How can I assume that MonoTouch does not support the extension of covariant / contravariant common interfaces? If so, what is the recommended workaround for this situation in MonoTouch?

+6
source share
1 answer

It actually depends on the compiler (and profile / runtime), and not on the Mono version. IOW, some things may work on Mono 2.10, not MonoTouch 6.x.

Current versions of MonoTouch come with a smcs compiler and a profile based on 2.1 (mainly Silverlight and some .NET 4.0 add-ons).

New features, such as covariance, require a full 4.0 compiler (for example, dmcs in Mono 2.10 or mcs in Mono 3.0) and runtime.

Future versions of MonoTouch (probably this spring with alpha / beta at the beginning of 2013) will provide 4.0 / 4.5 runtime and compiler.

+6
source

All Articles