IronRuby & DynamicObject.TryGetMember returning null

I am working with IronRuby and a DynamicObject derived class to create a
proxy layer for a game scripting engine that allows me to intercept gets
and sets and do things like mark objects for saving, potentially
security checks, etc.

But I’m finding that if my TryGetMember returns true, but sets the out
result param to null, then IronRuby seems to hang indefinitely.

I’ve created a pretty concise repro case here:

can anyone shed some insight into this problem? So far, I’m loving
IronRuby.

best,

–ben joldersma

Heads up, looks like this applies to the Expando object as well, here’s
an even simpler gist:

Try implementing TryInvokeMember.

In IronRuby “d.foo” actually gets and invokes “foo”, so it will use
DynamicObject’s TryInvokeMember. This is different from IronPython and
C# where method calls are two operations: TryGetMember (d.Foo) and
TryInvoke (d.Foo()). The rough IronRuby equivalent to this is
d.method(:foo).call().

~js

Okay, very interesting stuff. I had seen you and others suggest that in
other places, but I thought I was insulated from it, because I was
implementing TryInvokeMember! After further examination, I seem to have
stumbled to a solution.

In my actual code, I was trying to return a function delegate in the
TryGetMember, when the member in question is a method. I think that
this, coupled with the TryInvokeMember implementation was causing some
badness. So I removed the delegate creation code in TryGetMember, and
just handle properties, and then in TryInvokeMember, I handle both
methods and properties (this seems to work!)

Thanks a million for your help!

Next problem: I’m hesitant to bring it up again, maybe I should be able
to figure this out on my own, but it’s stumped me for quite a spell now.
I’m getting a System.InvalidOperationException that says “No coercion
operator is defined between types ‘System.String’ and
‘IronRuby.Builtins.MutableString’” when I try and call a method on one
of my dynamic objects with a literal Ruby string.

I’ve created another gist that reproduces the problem here:

If I write ‘test’.to_clr_string, this works, but that seems like kind of
a pain to have to do in my scripts…

Any ideas about this? The difficult part about it is that it doesn’t
even seem the runtime even gets to the point where any of my overrides
are executed - no breakpoints are hit in MonoDevelop, no console output,
so I don’t think I can fix it from that vantage point… Any help is
much appreciated.

best,

–ben