By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

Simple Generics should be CLS Compiliant

P: n/a
Currently, generic types are not CLS compliant. This puts library authors in
a quandry who are faced with three bad alternatives:
1. CLS Compliance but no generics,
2. Using generic types but losing CLS Compliance, or
3. Supporting both, bloating the code and muddying the waters with dual
versions of generic classes.
This latter is seen in mscorlib with collections classes, Nullable, and
EventHandler as examples.

I believe there is a simple alternative. Allow simple generic types -- those
with at most base class constraints -- to be consumable by any CLS language.
How? Since not all languages can specify the generic parameters, have these
default to the base class constraint.

Imagine generic List is accessed from a language with no support for
generics. List<UNSPECIFIED> is interpreted as List<object>. Isn't that
equivalent to ARRAY_LIST? Isn't Dictionary<object,object> the same as
Hashtable? Isn't EventHandler<EventArgs> the same as EventHandler? Have the
CLI interpret older tokens of newly-generic types in this way.

This schema renders the non-generic variants unnecessary. So let's get rid
of them, using these simple generics. This provides one simple GENERIC way to
create new types, even if I want them to be generic *and* referenceable from
any .NET language (i.e. CLS compliant).

This is the subject of my suggestion FDBK39498. Personally, I think this is
pretty important. Please have a look there and make your vote.
Nov 2 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
> Currently, generic types are not CLS compliant.

Yes they are.

Nov 2 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.