Forum: IronRuby Linebreak issue with clr strings manipulated by Ruby code

Posted by Aldinei Sampaio (Guest)
on 2011-02-25 13:46
(Received via mailing list)
Hi, guys. Sorry if I am posting this in the wrong place, but I need
some kind of direction here.

I isolated my problem in the following UnitTest in Visual Basic:

<TestMethod()>
Public Sub LineBreakProblem()
    Const SCRIPT = "print System::String.Format('Line1{0}Line2',
System::Environment.NewLine)"

    Dim engine = IronRuby.Ruby.CreateEngine()
    Dim stream = New IO.MemoryStream
    Dim writer = New IO.StreamWriter(stream)
    engine.Runtime.IO.SetOutput(stream, writer)
    Dim source = engine.CreateScriptSourceFromString(SCRIPT, "Script",
Microsoft.Scripting.SourceCodeKind.File)
    source.Execute()

    writer.Flush()
    stream.Position = 0
    Dim actual = (New IO.StreamReader(stream)).ReadToEnd()

    Dim expected = String.Format("Line1{0}Line2", Environment.NewLine)

    Assert.AreEqual(expected, actual)
End Sub


As you can see, i am running this Ruby code:

print System::String.Format('Line1{0}Line2', 
System::Environment.NewLine)

And then I am using the engine.Runtime.IO.SetOutput to get back the
result generated by the "print" statement. System.Environment.NewLine
returns the char combination CR + LF.

The "expected" variable will contain: "Line1" + CR + LF + "Line2".
The "actual" variable receive the value "Line1" + CR + LF + CR + LF + 
"Line2"

Seems that all the linebreaks are doubled when using the CLR string
with the "print" statement.

Any suggestion that you can give me to resolve or work around this
problem will be much appreciated.
Posted by Aldinei Sampaio (Guest)
on 2011-03-04 00:38
(Received via mailing list)
Hi, sorry again, but is anyone seeing this message?

I coudnt get any response about this, either here or in the Codeplex
issue tracker.

2011/2/25 Aldinei Sampaio <aldinei.sampaio@gmail.com>:
Posted by Jimmy Schementi (Guest)
on 2011-03-04 22:33
(Received via mailing list)
Yes, I can reproduce this. I'll look into it. Have you opened a bug?
I'll follow up there.
~Jimmy



On Thu, Mar 3, 2011 at 6:11 PM, Aldinei Sampaio
Posted by Aldinei Sampaio (Guest)
on 2011-03-07 12:29
(Received via mailing list)
Yes, i created the issue #5836.

Thank you very much.

2011/3/4 Jimmy Schementi <jimmy@schementi.com>:
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.