Generics and CLS compliance…


This is dated news by now, but since I missed it, you might have as well. It was decided back in December that Generics would be CLS-compliant for Whidbey.

This is very good news. While I fully expected customers to use generics in Whidbey regardless of whether it was included in the CLS, not having it in the CLS would have required that library designers who wanted to follow the rules would either have had to avoid using generics or provide both generic and non-generic constructs. Neither of those approaches are very good.

Comments (2)

  1. I have one question:

    is the following schema CLS compliant

    namespace A {

    class Foo {

    }

    class Foo <T> {

    public void Add (T x) {}

    }

    }

    csc beta1 accepts it, but we consider it BAD. In Nemerle, we have the type inference engine, which allows

    you to write

    def x = Foo ();

    x.Add (1)

    instead of C#’s

    Foo <int> x = new Foo <int> ();

    x.Add (1);

    now as you can see, the presence of some type in two versions in the same place makes type inference harder.

  2. Alex says:

    Thank goodness – I had not heard this. We do several exposed Class Libraries which we require to be CLS compliant. The previous non-compliance was going to mean that Generics would pass us by. This was to us a far bigger issue than edit & continue etc… But one that got almost no coverage.

Skip to main content