Interface constraint seems ignored with generics

I have the following interface and function (porting from C#):

public interface IComparable
{     int CompareTo(object o);
}

public interface IComparable<T>
{    int CompareTo(T o);
}

    public class Utils : NativeModule
    {
        public Utils()
        {

        }
       public static IEnumerable<KeyValuePair<T, T>> PairPermutations<T>(this IEnumerable<T> values) where T : IComparable<T>
       {

           List<KeyValuePair<T,T>> result = new List<KeyValuePair<T,T>>();
           foreach (T value1 in values)
               foreach(T value2 in values)
                   if (value1.CompareTo(value2)!=0)
                       result.Add(new KeyValuePair<T,T>(value1,value2));
           return result;
           /
           return from value1 in values
                           from value2 in values
                           where value1.CompareTo(value2) != 0
                           select Tuple.Create(value1, value2);
           /
       }

}

it gives me this error:

Utils.uno(28,25): E3104: 'Utils.PairPermutations`1.T' does not contain a member called 'CompareTo'. Could you be missing a package reference?

the line number referring to: if (value1.CompareTo(value2)!=0)

which doesn’t make sense, since I’ve constrained the type of T to implement IComparable

Hi,

I’m sorry this took 5 months, but Uno version 0.30 will finally give you a fix for this.

Thanks for the bug report :slight_smile: