Forum: IronRuby Interface methods of internal class not defined in IR

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4542833c109b143eeadf55450590da4a?d=identicon&s=25 Xerxes Battiwalla (xerxesb)
on 2009-05-11 07:50
(Received via mailing list)
Hi there,

We are using a .NET library which comprises of several classes marked
internal where each class exposes functionality through an interface.
When attempting to call on these objects in IR, we get an "undefined
method" exception. Is there a way to access the interface members of
the class when it's internal?

I've created the following example to reproduce:

******* In C#:

using System;

namespace HelloWorldApp
{
    public class HelloFactory
    {
        public IHelloWorld NewWorld()
        {
            return new HelloWorld();
        }
    }

    public interface IHelloWorld
    {
        void SayHello();
    }

    internal class HelloWorld: IHelloWorld // NOTE THE INTERNAL MODIFIER
    {
        public void SayHello()
        {
            throw new NotImplementedException();
        }
    }
}


******* In Ruby:
require "HelloWorldApp.dll"

class HelloWorldApp::HelloWorld
  def say_hello
    puts "Hello!!"
  end
end

@hello_factory = HelloWorldApp::HelloFactory.new
@hello_app = @hello_factory.new_world

puts "hello_app should be HelloWorldApp::IHelloWorld but was
#{@hello_app.class}"
@hello_app.say_hello

*********

In this example, I expect the system to puts "Hello!!", but instead it
throws the "undefined method" exception. If I run IR with the
PrivateBindings option it works, but it seems like a workaround I
shouldn't have to do, because i'm passing the instance from C# to IR
as the interfaced type (my conclusion therefore being it should be
able to access it)

Any help appreciated.

Thanks,
Xerx.
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-05-11 08:53
(Received via mailing list)
You are right - it should work. We know about this issue. I'll look at
fixing it soon, maybe this week.

Thanks,
Tomas
This topic is locked and can not be replied to.