Friday 5 December 2008

Calling .NET libraries from IronRuby

In my recent post on IronRake I've used the following task to demonstrate the power of IronRake:

task :default do
  require 'mscorlib'

  require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  print System::Guid.NewGuid().ToString()
end

And now I can tell you that everything is much simpler that that. Don't use "require" plus full assembly name. Use the following:

require 'mscorlib'

task :default do
    include System
    print Guid.NewGuid.ToString
end

"Include System" is much shorter, isn't it? :)

No comments: