Skip to content

Conversation

@adamsitnik
Copy link
Member

We are no longer going to support System.CommandLine.Rendering.

The SystemConsole that was used by dotnet format was just a wrapper around System.Console: https://github.com/dotnet/command-line-api/blob/3bbb940ceeb3254790899d751a8d418348563d40/src/System.CommandLine.Rendering/IO/SystemConsole.cs#L9

Since other projects in this repo were already using Microsoft.Extensions.Logging.Console, it felt like the best alternative.

@adamsitnik adamsitnik requested a review from a team as a code owner January 22, 2025 13:20
@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Jan 22, 2025
string? verbosity,
string? binarylog,
string? report,
IConsole console);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this delegate was using IConsole abstraction from System.CommandLine.Rendering. Initially I just wanted to update it, but then I got to the conclusion that it's not being used anywhere and can be deleted. But I can be wrong as not all VS features work for me when I work with a local build of the SDK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we missed removing this in a refactor at some point. Thanks!

@adamsitnik
Copy link
Member Author

I've added the NO MERGE label to ensure that it's not merged before the Preview 1 snap.

@JoeRobich
Copy link
Member

@adamsitnik I tried out using the SimpleConsoleLogger from Logging.Console and it doesn't give the experience we are looking for. Always writing a "info:" prefix clutters the output. Could we add a simpler logger like the one implemented in dotnet/roslyn-tools@c60d28f?

@adamsitnik
Copy link
Member Author

I tried out using the SimpleConsoleLogger from Logging.Console and it doesn't give the experience we are looking for.

@JoeRobich big thanks for giving it a try!

Always writing a "info:" prefix clutters the output.

In such a case I am going to revert some of my changes and bring back the old behavior, just without using IConsole from rendering.

!(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS())
&& !Console.IsOutputRedirected;

private readonly static object _gate = new object();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the gate static, as Console is a static singleton and I expect that we want to prevent from multiple threads changing the color.

internal class SimpleConsoleLogger : ILogger
{
private readonly object _gate = new object();
private static readonly bool ColorsAreSupported =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsitnik
Copy link
Member Author

@JoeRobich done, PTAL

@JoeRobich
Copy link
Member

@JoeRobich done, PTAL

Looks good to me. Thanks!

@adamsitnik
Copy link
Member Author

/ba-g the tiemouts are know infra problems, but despite that the Build Analysis is red

{CCBF3A64-1FC6-4BE2-B083-C6EE9F754D0C}

@adamsitnik adamsitnik merged commit 128068c into dotnet:main Jan 30, 2025
36 of 38 checks passed
akoeplinger added a commit that referenced this pull request Jan 30, 2025
adamsitnik added a commit to adamsitnik/roslyn-analyzers that referenced this pull request Feb 3, 2025
ViktorHofer pushed a commit to dotnet/roslyn-analyzers that referenced this pull request Apr 14, 2025
* remove the dependency to System.System.CommandLine.Rendering similarly to what I did in dotnet/sdk#46209

* update to latest System.CommandLine

* add the missing nuget feed

* Apply suggestions from code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Infrastructure untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants