Console.BackgroundColor behavior changes when console buffer is full - by johndog

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 727412 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/29/2012 7:38:09 PM
Access Restriction Public


Using the Console class to change the current BackgroundColor and write some text has different behavior, based on whether the console window's buffer is full.  If the buffer is not yet full, the background color for only the text output is modified.  If the buffer is full, the background color for the next output line is modified.

There are two issues at play here:

1) The behavior changes based on whether the console buffer is full.  This makes it very difficult for a developer to predict which behavior they will get, and may introduce bugs based on observations made when the console buffer is not full.  The developer has no visibility into whether the buffer is full or not, nor any reason to believe that will be a factor in behavior.
2) The behavior when the console buffer is full (which is going to be common behavior in long-running console windows) is particularly difficult to program to, in trying to selectively color text.  Newlines in the text, writing long text that wraps and the use of the WriteLine() API will all cause the colors in new lines to be messed up in this scenario.
Sign in to post a comment.
Posted by Microsoft on 5/8/2012 at 9:37 PM
Hi John!

Thanks for bringing up this interesting issue. We are always grateful when customers point towards potential concerns - this helps us ensuring the quality of the .NET Framework and driving the product into the right direction.

Indeed, you have discovered a genuine problem with the system.
Unfortunately, the issues appears to be external. When setting the background colour, we use the Win32 API SetConsoleTextAttribute. The behaviour you describe is just a the way a Windows console behaves. I agree that the exhibited behaviour is not what a user might expect in some circumstances, however, we do not plan to address it on the .NET side in the immediate future.

I thank you for your time and your contribution.

(Software Engineer on the .NET Base Class Libraries team)
Posted by Microsoft on 5/8/2012 at 3:45 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by MS-Moderator08 on 3/15/2012 at 5:06 AM
Thank you for reporting this issue. Could you please attach some screenshots about this issue?
Posted by MS-Moderator01 on 3/1/2012 at 1:39 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(