Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Does MonoTouch support variant generic interfaces?

RodneyFoleyRodneyFoley USBeta ✭✭
edited December 2012 in Xamarin.iOS

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 get 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 generic interfaces yet? What is the recommend workaround for this situation in MonoTouch?

Posts

  • prashantvcprashantvc USXamarin Team Xamurai

    Linking your StackOverflow question :)
    stackoverflow.com/q/14093332/85606

    @poupou: 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.

Sign In or Register to comment.