[Ironruby-core] getting the runtime type

Jimmy Schementi Jimmy.Schementi at microsoft.com
Sun Nov 29 09:00:50 EST 2009

Every Ruby class is not mapped to a unique CLR type (they are all IronRuby.Builtins.RubyObject unless you subclass a CLR type or implement and interface). So doing the IronPython ClrMetaClass equivalent would require a speciic feature in IronRuby to give more control of the underlying CLR type -- IronPython has already added this in the form of "__clrtype__".

This work is not planned for 1.0, but definitely leaves a usability hole in our CLR integration. The work-around is to create a empty C# class, and then subclass it from Ruby -- there will be a unique CLR class generated for this Ruby class. Things like CLR attributes need to go on the C# class.

Sent from my phone

On Nov 29, 2009, at 4:07 AM, "Ivan Porto Carrero" <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> wrote:


I'd like to get the runtime type of a ruby class

The IronPython guys can do something like this (python substituted for ruby)
require 'clr'

class Person < Struct.new(:id, :name, :age)

they can then do clr.ClrType(Person).FullName

Something equivalent to that doesn't exist yet for ironruby does it?

When I do Person.to_clr_type it returns nil
and other objects give me their base types

Person.GetType => IronRuby.Builtins.RubyObject

I'm actually trying to get the ironpython ClrMetaClass from Harry Pierson written in ironruby.
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: <http://flanders.co.nz> http://flanders.co.nz
Google Wave: <mailto:portocarrero.ivan at googlewave.com> portocarrero.ivan at googlewave.com<mailto:portocarrero.ivan at googlewave.com>
Twitter: <http://twitter.com/casualjim> http://twitter.com/casualjim
Author of IronRuby in Action (<http://manning.com/carrero>http://manning.com/carrero)

Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091129/caae33b7/attachment.html>

More information about the Ironruby-core mailing list