[Ironruby-core] Overriding CLS Virtuals

Curt Hagenlocher curth at microsoft.com
Tue Sep 16 19:14:50 EDT 2008

Right now, the only way to get properties is to implement an interface that defines them.  When IronRuby supports this "natively", it will have to define a syntax for doing so.  That's because the Ruby language supports neither properties, attributes nor static types - all of which will be needed.  This will probably involve adding some new methods to Class that allow you to define typed CLS members.  But we don't have a specific timeframe for implementing this yet.

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Stefan Dobrev
Sent: Wednesday, September 10, 2008 2:46 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

Are we going to have "real" properties under the hood, because what we have for now is just method with "get_PropertyName"? And this did not play nicely with databinding.

I think the same question applies for events as well.

2008/9/9 Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>>

I've committed some changes to IronRuby (in SVN revision 141) that let you implement CLS interfaces and override virtual methods on CLS base types.  Interfaces work like Ruby modules, so to make your class implement IDisposable you could say

require 'mscorlib'

class Disposable

  include System.IDisposable

  def Dispose

    # Do something



You can also override virtual properties.  A class or interface that has the C# declaration "string Value { get; set; }" is overridden from IronRuby with methods named "Value" for the getter and "Value=" for the setter.

Note that you need to use the same casing as the CLS definition for both methods and properties.

We're just getting started with better .NET interop support and don't have very much test coverage yet - but this should let you get going on some more sophisticated interop scenarios than were previously possible.


Curt Hagenlocher

curth at microsoft.com<mailto:curth at microsoft.com>

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/20080916/d02240fa/attachment.html>

More information about the Ironruby-core mailing list