Bug 22262 - System.Console not echoing ReadLine to external console.
Summary: System.Console not echoing ReadLine to external console.
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-21 11:54 UTC by Ruffin
Modified: 2015-01-16 21:10 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example of console not echoing but of text being "read". (45.72 KB, image/png)
2014-08-21 11:54 UTC, Ruffin
Details

Description Ruffin 2014-08-21 11:54:30 UTC
Created attachment 7756 [details]
Example of console not echoing but of text being "read".

I am using the SqlDb# library (https://github.com/ruffin--/SqlDbSharp) and testing its ISQL client in a console application run from Xamarin Studio.  ReadLine() calls are not echoing what the user types as they type it, though the input is registering on <return>.

This is in Xamarin Studio 5.2.1 (Build 1) on Mac OS X 10.9.4.  

I think it's Mono v 3.6.0, though that's not an option in Bugzilla right now.  Here's what I get from `mono --version`:
Mono JIT compiler version 3.6.0 ((no/f540f8a Tue Jul 15 19:37:27 EDT 2014)

Initial report of the bug on the forums here:
https://forums.xamarin.com/discussion/17460/console-readline-from-imported-project-not-echoing-inputed-text-is-running-on-external-console#latest

Michael Hutchinson suggested I should file the bug here, in Class Libraries.  

I'm going to repeat some (essentially all) of that post's information here in the bug report.

I have a reasonably complex command line project that I started in Visual Studio Express 2012 on Windows, and have imported to Xamarin Studio 5 on my Mac. I've adjusted a few things -- I ran into "not built in active configuration" issue initially, and had to set up Run on external console. Otherwise it is unchanged.

Note that the most recent version of the SqlDb# library includes a dependency, though when I initially found this bug and reported it, I made a quick stash here that does not:
https://github.com/ruffin--/SqlDbSharp/archive/stashiges.zip

To be doubly clear, I do have "Run on external console" checked. I am seeing Console Writes, but not the echo for ReadLine().

So the ISQL project runs fine, but when I enter in characters after a Console.ReadLine() call, they aren't echoed. They are read -- the app runs, and it even echoes what I've typed after I'm "done" -- sometimes. Here's the code in the immediate context; nothing squirrelly:

Console.Write("SqlDbSharp> ");
while (!strInput.Equals("."))
{
    strInput = Console.ReadLine();
    if (!strInput.StartsWith("--"))
    {
        strCmd += strInput + " ";
    }
}

Once I'm out of the loop, occasionally, if there's no exception thrown while I process strCmd, I eventually get to see the echo, but only after I get a few lines further down into the app.

I can create a simplest case console app in Xamarin Studio and have it behave as expected.

public static void Main (string[] args)
{
    Console.WriteLine ("Enter something.");
    string somethingRead = Console.ReadLine ();
    Console.WriteLine (somethingRead);
}

That does fine. It echoes everything I type as I type, just as I'd expect the larger, imported, Visual Studio-first app to work.

Fwiw, the text I entered is echoed once I get past line 190 in Isql.cs, object objResult = parser.executeCommand(strCmd);

If you want to recreate exactly what I'm using when the error occurs, it's from here, pushed to a stashes branch: https://github.com/ruffin--/SqlDbSharp/archive/stashiges.zip

Note that the "database engine" is pretty (okay, insanely) hacky.  You should be able to run the following test SQL, however:

=== BEGIN TEST COMMANDS BELOW ===
CREATE TABLE TestTable (
        ID INTEGER (4) AUTOINCREMENT,
        CITY CHAR (10));

INSERT INTO TestTable (CITY) VALUES ('New York');
INSERT INTO TestTable (CITY) VALUES ('Boston');
INSERT INTO TestTable (CITY) VALUES ('Fuquay');

SELECT * FROM TestTable;
.
=== END OF TEST COMMANDS; DO NOT INCLUDE THIS LINE ===

Note that the ending line with a period by itself is required.  And also note that the commands are read and work (see screenshot invisibleCommands.png to see the results of pasting in the above test SQL).  Note that the screenshot is in Terminal.app.  I changed the default colors, but am not using another term window provider.
Comment 1 Rodrigo Kumpera 2014-08-26 00:05:42 UTC
Please provide a test case that shows the bad behavior.

Your simple example, as you mentioned, works fine.
Comment 2 Ruffin 2014-12-23 21:29:54 UTC
You should be able to follow the directions in the bug to use that library and reproduce it. I've just done it.

There's a stash here:
https://github.com/ruffin--/SqlDbSharp/archive/stashiges.zip

Run that, and you should see the issue.

Note You need to log in before you can comment on or make changes to this bug.