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
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Letterle
Sent: Friday, December 05, 2008 1:58 PM
To: [email protected]
Subject: Re: [Ironruby-core] Handling C# lower case namespaces
Just monkey-patch it:
class System::Int64
def inspect
self.to_string.to_s
end
end
On Fri, Dec 5, 2008 at 4:50 PM, Tomas M.
<[email protected]mailto:[email protected]>
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):
System::Type.get_type(“foo.bar.baz”).to_class
As for Int64… it prints #System::Int64:0x000005e, which is not
particularly useful. It should probably call ToString. I’ll file a bug.
Tomas
From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Aaron F.
Sent: Friday, December 05, 2008 1:07 PM
To: [email protected]mailto:[email protected]
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.