First drop of RubyCLR

Here’s the first drop of RubyCLR.

I think this version is usable for folks who are interested in playing around with the current state of the bits. It supports constructor and method overloading, static and instance methods, properties, indexers, static and instance fields, events, multi-dimensional arrays, primitive (ints, floats, bools) value-type marshaling, and reference-type marshaling. Look at the tests2.rb unit test file to see the evidence.

Notable are the things that this release does not support. There is no support for generics, nor is there support for marshaling user-defined value types like Point.

There’s a rakefile in this project too if you want to compile the bits. I’ve included a compiled DLL for folks who don’t have MS C++ 14.0 installed on their computer.

This release requires the RTM version of .NET 2.0.

I haven’t tried to build anything using these bits yet outside of the unit tests, but I wanted to provide a drop for the curious.

I’m really interested in getting feedback about the implementation of the bridge. If folks have the time and could do a code review of either the C++ or Ruby code (or both!) I would greatly appreciate it.

Bug reports in the form of a unit test that can repro the bug would also be greatly appreciated.

The state of error messages in this release is more-or-less non-existent. I plan on fixing this once I tackle the next two hard problems: marshaling user defined value types and handling generics.

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

14 Responses to “First drop of RubyCLR”

  1. any chance to make it work with mono on linux?

  2. Not in the immediate future. The problem is that I use Managed C++ extensively in this bridge, and there’s no equivalent for Mono. I guess you could use P/Invoke for most things using C#, but that would be painful … perhaps someone could volunteer to port the C++ part of the bridge (which is currently larger than I would like it to be ~900 lines or so) to C#?

  3. Scott Hanselman 15. Jan, 2006 at 1:51 am

    This rocks, you’re a total Ruby Stud. Keep it coming!

  4. I don’t see the DLL – where is it in the zip?

  5. It’s called RbDynamicMethod.dll and it’s in the /Tests directory.

  6. John,
    I got unit tests you shipped to pass, but when I tried to display a message box using Windows Forms, I got an error. It looks like there is a hard-coded set of assemblies that this drop will deal with – is that true?
    Anyways, here is a unit test showing the problem:
    class FormsTest < Test::Unit::TestCase
    def test_message_box
    include System::Windows::Forms
    m = System.Windows.Forms.MessageBox.Show(“Hello, world!”)
    end
    end

  7. Reposting unit test in hope it won’t format it weirdly again …

    class FormsTest < Test::Unit::TestCase
    def test_message_box
    include System::Windows::Forms
    m = System.Windows.Forms.MessageBox.Show("Hello, world!")
    end
    end
    
  8. When you say there is no support for generics, does that mean that you just can’t create an instance of a generic type or call a generic method? or that generic types aren’t handled at all (as return values, etc)
    Any chance you could help me interpret this error?
    (eval):45:in `ProcessStdf’: (eval):45:in `ProcessStdf’: compile error (SyntaxError)
    (eval):45: unterminated string meets end of file
    from (eval):171:in `send’
    from (eval):171:in `method_missing’
    from parse.rb:14
    I’m hooking it up to a data file parsing library of mine. I use generic EventHandlers, could that be the cause?
    I really love this thing. Could be very useful for me. Let me know if you want me to test new drops in the “real world” I’ve got several applications for it.

  9. Yup, it was EventHandler<T>. Works great. Can’t wait for generics support and user-defined ValueType marshaling.

  10. I’m glad you’re using it, Mark!
    I have some crude UDF value type marshaling working in a private build right now, but I haven’t had any cycles to work on it the past couple of weeks since I was giving birth to a new ASP.NET 2.0 class …
    After some recovery time this weekend, I’ll be back at work hacking on this next week.
    Hang in there – more code soon!

  11. I realized that for my immediate purposes, I really only need support for Nullable<T> where T is one of the primitives you already support. So, I hacked your code to special case Nullable for those types. It now basically gives the same semantics to Nullable as boxing. You get nil if it’s “null”, otherwise, you get the value. It works great! Now I can mine my datafiles with ease. I’m happy to share the changes if you like.
    It’s quite cool because I am using DynamicMethod in my C# library to dynamically generate record parsers for my data files.

  12. I’m glad it’s working out for you, Mark!
    Please feel free to share your code- I’d be interested in seeing how you added that feature to my codebase. You can reach me more directly via jlam at iunknown.com

  13. This is fantastic!
    I just downloaded the drop.
    As soon as I get the chance to play around with this I will probably blog about my experiences. I expect a lot of buzz around this bridge in the future.

  14. Thanks, Philipp. Hopefully I’ll get a value type drop out soon; it’s proving to be a slightly tougher problem than it looked the first time I hacked out an implementation.