C# method returns string to IronRuby - how it automatically be a IronRuby string?

Hello,

Just hosted the DLR within an application to allow users some
scripting functionality. Part of the functionality is that you can
call a C# method and have a string returned. However, the string is
always being returned as a ClrString which means methods like << don’t
work which is annoying. Having to write to_s after every call isn’t
great for my nice clean DSL :slight_smile:

How can I get around this? I want my C# method to return Ruby string.

Thanks

Ben

Monkey patch ClrString with the methods you need?
Or make your C# method return MutableString if you are able to

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

Do you have the latest build of IronRuby?
Non-mutable Ruby methods are implemented there on CLR strings.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Ivan Porto
Carrero
Sent: Thursday, April 16, 2009 9:12 AM
To: [email protected]
Subject: Re: [Ironruby-core] C# method returns string to IronRuby - how
it automatically be a IronRuby string?

Monkey patch ClrString with the methods you need?
Or make your C# method return MutableString if you are able to

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

On Thu, Apr 16, 2009 at 5:59 PM, Ben H.
<[email protected]mailto:[email protected]> wrote:
Hello,

Just hosted the DLR within an application to allow users some
scripting functionality. Part of the functionality is that you can
call a C# method and have a string returned. However, the string is
always being returned as a ClrString which means methods like << don’t
work which is annoying. Having to write to_s after every call isn’t
great for my nice clean DSL :slight_smile:

How can I get around this? I want my C# method to return Ruby string.

Thanks

Ben


Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

I am using 0.3 build but I can grab the latest tomorrow. If that fails
I will give MutableString strings a try - thanks for the responses :slight_smile:

On Thu, Apr 16, 2009 at 6:27 PM, Tomas M.