[Ironruby-core] Handling C# lower case namespaces

Tomas Matousek Tomas.Matousek at microsoft.com
Fri Dec 5 17:10:38 EST 2008

Thumbs up :)

You might however expect this to work for all CLR types. In which case you can indeed monkey patch it as well (kind of):

>>> class Object
...   def to_s
...     self.class.name[0,8] == "System::" ? to_string.to_s : super
...   end
... end
=> nil
=> nil
>>> require 'mscorlib'
=> true
=> nil
>>> System::Convert.to_int64(1234)
=> 1234


From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Michael Letterle
Sent: Friday, December 05, 2008 1:58 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Handling C# lower case namespaces

Just monkey-patch it:

class System::Int64

     def inspect


On Fri, Dec 5, 2008 at 4:50 PM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote:

Well, that's very unfortunate. They seems to break .NET guidelines for namespace naming. It's not compatible with Ruby language to have lowercased namespaces since they behave like modules. Module names must start with an upper case. We can add some API to overcome this, but it won't be pretty. Something like

clr.class_get :foo, :bar, :baz would return class for type foo.bar.baz.

For now you can use reflection API to get the type (and Ruby class for that type):


As for Int64... it prints #<System::Int64:0x000005e>, which is not particularly useful. It should probably call ToString. I'll file a bug.


From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Aaron Feng
Sent: Friday, December 05, 2008 1:07 PM
To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: [Ironruby-core] Handling C# lower case namespaces

It seems like the current version does not handle lower case namespaces when referencing a .NET DLL.  It thinks it is a method call whenever a constant starts with lower case.  It also doesn't handle non-alphabet characters such as _ (underscore).

I'm trying to call WCF service from IronRuby via the proxies file.  svcutil converts all namespaces in the proxies file to lower case.  Here's some info on it:


I also noticed that "puts" does not output the value of Int64.  However, it does if I use Console.WriteLine in my ruby program.

Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>

Michael Letterle
[Polymath Prokrammer]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/201d6647/attachment.html>

More information about the Ironruby-core mailing list