IIRC you can open "concrete" generics, but not "open" ones: In plain english
this means you can add methods to List<string> but not List<T>.

This is essentially because List<T> isn't a real type in the CLR, it's
basically some metadata that can be used to build a real type when the T is
supplied.

You could as an alternative add methods to the underlying non-generic
IEnumerable interface, but then you'd have to do some run-time reflection to
figure out that your List is actually a List<string>... This is probably not
nice.

In theory when CLR4 lands and has support for co/contra variant generics,
List<object> should match List<string> and everything else, but I don't know
if IronRuby would also work for this?

Good luck

On Tue, Feb 2, 2010 at 7:52 AM, Ryan Riley <ryan.ri...@panesofglass.org>wrote:

> I have been trying to figure out how to Rubify generic extension methods
> for use with the likes of Rx, Open XML SDK, etc. Ivan went over it a bit
> with me this weekend, but I'm still having difficulty including a module
> within a .NET type. Is that even possible?
>
> ...
>
> The questions I'm not able to answer are:
>
>    1. Can I somehow open up a .NET class, say
>    System::Collections::Generic::List[T] and include the EnumerableExtensions?
>    So far, I'm finding that's a no.
>    2. How do I hook in the included(base) method above? I'm assuming
>    that's a one-time call, but I don't see anywhere that it's called when a
>    module is included. Do I need to use a before_filter or perform that action
>    at the beginning of the linq_select method?
>
>
> Thanks!
>
> Ryan Riley
>
> Email: ryan.ri...@panesofglass.org
> LinkedIn: http://www.linkedin.com/in/ryanriley
> Blog: http://wizardsofsmart.net/
> Twitter: @panesofglass
> Website: http://panesofglass.org/
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to