0

I am self-hosting IronRuby and want to use a .NET assembly "Math.dll" which uses the "Math"-namespace. I can use other assemblies but not this one:

require "Math.dll"
require "Unsafe.dll"

consts = Math.constants
#consts = Unsafe.constants

consts.each { |const| 
  System::Console.WriteLine( const) 
}

It only returns "PI" and "E" given by the ruby math module. Using the other assembly returns the .net classes defined in it. Both assemblies are used by the hosting program in the same way.

DLR-version: 1.1.0.1 Ironruby-version: 1.1.0.0, 1.1.3.0 and 1.1.4.0(6th juli 2014)

Max
  • 81
  • 1
  • 4

1 Answers1

0

Workaround for this problem but not a general solution:

  1. Get the source code
  2. In the IronRuby.Library project change in the line

    [RubyModule("Math")]
    

    in RubyMath.cs, or

    DefineGlobalModule("Math", typeof(IronRuby.Builtins.RubyMath), 0x0000000F, LoadMath_Instance, LoadMath_Class, LoadMath_Constants, IronRuby.Builtins.RubyModule.EmptyArray);
    

    in Initializers.Generated.cs, the "Math" string (e.g. "Math__").

Now you could combine it:

require "Math.dll"

module Math
    include Math__
end
consts = Math.constants

consts.each { |const| 
  System::Console.WriteLine( const) 
}

I don't know if there are any dependencies affected.

Max
  • 81
  • 1
  • 4