Sounds like a good idea to me. I’d like to suggest my codebuilder gem
for
code generation. It’s based on John’s previous RubyCLR, and takes
inspiration from the xmlbuilder in Rails, for building .NET classes.
For
example, running the little script below:
require ‘rubygems’
require ‘codebuilder’
@not_implemented = { “RubyString” => [“public_methods”],
“RubyInteger” => [“ancestors”]}
result = CodeDOM::Builder.new.build do |builder|
builder.namespace “IronRuby” do
@not_implemented.each do |klass, methods|
builder.partial_klass klass do
methods.each do |meth|
builder.method meth do # Array of parameters for the method
builder.csharp “throw new NotImplementedException();”
end
end
end
end
end
end
puts(result.render :csharp)
Gives you C# code like this:
namespace IronRuby {
using System;
using System.Data;
using System.Windows.Forms;
public partial class RubyString {
public virtual void public_methods() {
throw new NotImplementedException();
}
}
public partial class RubyInteger {
public virtual void ancestors() {
throw new NotImplementedException();
}
}
}
The tool is based on the CodeDOM framework in .NET. The script above
builds
a representation of the classes, methods, properties etc. that are
defined
and then ‘renders’ them to a source language (in this case, C#).
It’s not able to do attributes on methods but I bet I could add that
fairly
easily. It’s also not seen a lot of use (I use for an internal project
at
work but otherwise I’m not sure if anyone else ever has) but I’d be glad
to
provide whatever support would be needed.
I just uploaded my latest (5.0.10), which probably won’t be available
via
gem for a few hours, but the project itself is hosted at
http://rubyforge.org/projects/codedombuilder.
Justin
p.s. Just to re-iterate, this tool is based on C-Ruby and uses the
rubyclr
project. I fully intend to port it when IronRuby becomes capable enough