Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Proposal]: Add overloads to Console.Write that also take a ConsoleColor parameter #61731

Closed
FilipToth opened this issue Nov 17, 2021 · 5 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Console
Milestone

Comments

@FilipToth
Copy link
Contributor

Background and motivation

This API proposal should just make it easier to write things of different colors to the console. Right now, we have to call three methods to do so. This is how we would do that now:

Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Hello!");
Console.ResetColor();

This is what I propose:

Console.Write(ConsoleColor.Blue, "Hello!");

This isn't anything critical, it's just some sugar to make writing code a little bit easier.

API Proposal

namespace System
{
    public static class Console
    {
        public void Write(ConsoleColor color, String value);
    }
}

I would suggest having an overload for Write and WriteLine.

API Usage

System.Console.WriteLine(ConsoleColor.Red, "Red text!");

Alternative Designs

No response

Risks

I do not see any risks associated with this.

@FilipToth FilipToth added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Nov 17, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Console untriaged New issue has not been triaged by the area owner labels Nov 17, 2021
@ghost
Copy link

ghost commented Nov 17, 2021

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Issue Details

Background and motivation

This API proposal should just make it easier to write things of different colors to the console. Right now, we have to call three methods to do so. This is how we would do that now:

Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Hello!");
Console.ResetColor();

This is what I propose:

Console.Write(ConsoleColor.Blue, "Hello!");

This isn't anything critical, it's just some sugar to make writing code a little bit easier.

API Proposal

namespace System
{
    public static class Console
    {
        public void Write(ConsoleColor color, String value);
    }
}

I would suggest having an overload for Write and WriteLine.

API Usage

System.Console.WriteLine(ConsoleColor.Red, "Red text!");

Alternative Designs

No response

Risks

I do not see any risks associated with this.

Author: FilipToth
Assignees: -
Labels:

api-suggestion, area-System.Console, untriaged

Milestone: -

@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Nov 17, 2021
@adamsitnik
Copy link
Member

adamsitnik commented Nov 17, 2021

Hi @FilipToth

Thank you for your proposal. I am going to include this in #52374 which we may include in .NET 7 if the stars align. It would most probably be exposed by the new Terminal type, with all the colors supported by VT100.

@FilipToth
Copy link
Contributor Author

Ok, Great that would be awesome. Thank you.

@stephentoub
Copy link
Member

This is also a dup of #39746.

@adamsitnik
Copy link
Member

This is also a dup of #39746.

I've not noticed that. In such a case I am going to close this issue.

@FilipToth please follow #39746 and #52374 for updates. Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Console
Projects
None yet
Development

No branches or pull requests

3 participants