.Net<->IR Object Mapping

Hi,

Is there a table somewhere defining how .Net objects are mapped to Ruby
objects?

Thanks,
Shay


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

http://ironruby.net/Documentation/.NET/Names
http://ironruby.net/Documentation/.NET

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

I meant more like namespaces turn to modules, interfaces to modules,
enums to…? constants to…?

I’ll check it out now and write the results here.

Thanks for the reply!
Shay.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

http://ironruby.net/Documentation/.NET/QA_Plan

There is a table there that covers most of these. Let me know if you
need something that isn’t listed.

JD

…there is no try

Private method will map to a instance method, but only with
-X:PrivateBindings. Otherwise that looks great. Could I talk you into
updating the table and adding specs to
Merlin\Main\Languages\Ruby\Tests\Interop\net? Even just adding them to
uncategorized_spec.rb will work, I’ll move them around.

Thanks,

JD

…there is no try

Sure. Just give me a few days.

I’ll let you know when it’s done.

Shay.

http://www.ironshay.com
Follow me: http://twitter.com/ironshay

Thanks!

JD

…there is no try

With a build from the latest sources, the Cucumber C# example from
http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net is
working. Also, only two of the Cucumber tests fail. One seems to be a
test issue, and the other is because of
http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=22984.
Please try out Cucumber and let us know what your experience is.

One usability issue is that Cucumber uses the win32console gem to
color-code the results it prints to the console, so that failures are in
red, etc. However, the win32console is a native gem and does not work
with IronRuby, and so you do not get colored output. It should be quite
easy to implement the win32console library in pure Ruby code (but marked
with platform=“ironruby” as mentioned at
http://ironruby.net/Documentation/Real_Ruby_Applications/RubyGems) using
the System.Console functionality. Anyone interested in doing this?

Shri

2009/6/9 Shri B. [email protected]:

With a build from the latest sources, the Cucumber C# example from http://wiki.github.com/aslakhellesoy/cucumber/ironruby-and-net is working. Also, only two of the Cucumber tests fail. One seems to be a test issue, and the other is because of http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=22984. Please try out Cucumber and let us know what your experience is.

Why is the issue filed on IronPython?

The list on this page is great but it is not complete.

Here is what I came up with. Correct me if I’m mistaken:

.Net Object Ruby Object

Namespace Module
Interface Module
Class Class
Enum Class
Enum constant Class method
Constant Class method
Static method Class method
Property Getter and setter methods
Public method Instance method
Protected method Instance method
Private method Isn’t mapped at all
Delegate Class

I have to say that the delegate mapping is awesome!!!
I can’t say why, but using it with a code block is much more fun than
writing anonymous methods or lambda expressions in C# :slight_smile:

Thanks,
Shay.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

That’s called dynamic language interop - Dino’s fixing bugs in IronRuby
:))

I’ve filled it under IronRuby:
http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1535

Tomas

My mistake :slight_smile: It was not intentional.

It also seems like protected methods and internal classes are accessible
in IR just like they were public. Is it the correct behavior?

Thanks,
Shay.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

My mistake - internal classes are accessible only with
-X:PrivateBinding. Protected methods are always accessible like public
methods.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

By the way, even with “-X:PrivateBinding” I can’t access private
members. Should it be done in a special way?

Thanks,
Shay.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

Could you give an example where it doesn’t work?

Tomas

They are only accessible if called with a receiver that is an instance
of a derived class.
Or do you observe another behavior?

Tomas

I assumed a reflection like behavior… For example, doing something
like:
klass.method(:MyPrivateClrMethod).call

Can you write a simple example of what you’ve described?

Thanks,
Shay.


http://www.ironshay.com
Follow me: http://twitter.com/ironshay

I can’t get it to work… What am I doing wrong?

This is my C# code:
namespace IRTests
{
public class IRTest
{
private void MyMethod() {
Console.WriteLine(“Hi from C#”);
}
}
}

And this is the IR console:

t = IRTests::IRTest.new
=> IRTests.IRTest
t.my_method
:0: undefined method `my_method’ for IRTests.IRTest:IRTests::IRTest
(NoMethodError)

t.method(:my_method)
D:\IronRuby\GitRepository\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\KernelOps.cs:1437:in
method': undefined method my_method’ for class `IRTests::IRTest’
(NameError) from :0

Thanks!
Shay.

Shay F.
http://www.ironshay.com
Follow me: http://twitter.com/ironshay

Works just fine for me. How are you starting up the console? Here’s my
method:
[201] > ir -X:PrivateBinding
IronRuby 0.5.0.0 on .NET 2.0.50727.4918
Copyright © Microsoft Corporation. All rights reserved.

require ‘temp1’
=> true

IRTests::IRTest.new.my_method
Hi from C#
=> nil

JD

…there is no try