Getting the runtime type

Hi

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)
end

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 C.
Blog: http://flanders.co.nz
Google Wave: [email protected]
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

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.

~Jimmy
Sent from my phone

On Nov 29, 2009, at 4:07 AM, “Ivan Porto C.”
<[email protected]mailto:[email protected]> wrote:

Hi

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)
end

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 C.
Blog: http://flanders.co.nz http://flanders.co.nz
Google Wave: mailto:[email protected]
[email protected]mailto:[email protected]
Twitter: http://twitter.com/casualjim http://twitter.com/casualjim
Author of IronRuby in Action
(http://manning.com/carrerohttp://manning.com/carrero)


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Is the current best practice for this to create a custom class for any
Ruby
types that need CLR integration, or should we use
IronRubyInlinehttp://github.com/rvernagus/IronRubyInline?
I suppose it depends on your use case, but I would think the latter is
probably the best option. Thoughts?

Ryan R.

Email: [email protected]
LinkedIn: http://www.linkedin.com/in/ryanriley
Blog: http://wizardsofsmart.net/
Website: http://panesofglass.org/

On Sun, Nov 29, 2009 at 8:00 AM, Jimmy S. <

I want to use it for silverlight databinding, but it’s part of a bigger
plan
:slight_smile:

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Google Wave: [email protected]
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

IronRubyInline gives you a better workflow between writing C# and Ruby,
so it gives you nice way to create a CLR type, but both ways are
techically equivalent, so either way is fine. Personally I’d use the
inline option.

Keep in mind that ironrubyinline requires you to be able to call csc.exe
and write a DLL to disk at runtime, so make sure your environment
supports that – you might need to pregen the dlls in a partial trust,
for example, but for development it’s perfectly fine.

~Jimmy
Sent from my phone

On Nov 29, 2009, at 2:40 PM, “Ryan R.”
<[email protected]mailto:[email protected]> wrote:

Is the current best practice for this to create a custom class for any
Ruby types that need CLR integration, or should we use
IronRubyInlinehttp://github.com/rvernagus/IronRubyInline? I suppose it
depends on your use case, but I would think the latter is probably the
best option. Thoughts?

Ryan R.

Email: mailto:[email protected]
[email protected]mailto:[email protected]
LinkedIn: http://www.linkedin.com/in/ryanriley
http://www.linkedin.com/in/ryanriley
Blog: http://wizardsofsmart.net/ http://wizardsofsmart.net/
Website: http://panesofglass.org/ http://panesofglass.org/

On Sun, Nov 29, 2009 at 8:00 AM, Jimmy S.
<mailto:[email protected][email protected]mailto:[email protected]>
wrote:
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.

~Jimmy
Sent from my phone

On Nov 29, 2009, at 4:07 AM, “Ivan Porto C.”
<mailto:[email protected][email protected]mailto:[email protected]>
wrote:

Hi

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)
end

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 C.
Blog: http://flanders.co.nz http://flanders.co.nz

Google Wave: mailto:[email protected]
mailto:[email protected]
[email protected]mailto:[email protected]
Twitter: http://twitter.com/casualjim http://twitter.com/casualjim
http://twitter.com/casualjim
Author of IronRuby in Action
(http://manning.com/carrerohttp://manning.com/carrerohttp://manning.com/carrero)


Ironruby-core mailing list
mailto:[email protected][email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-corehttp://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
mailto:[email protected][email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-corehttp://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core