Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit b7627a4

Browse files
committed
Merge pull request #42 from dotnet/cleanconsole
Clean Console messages.
2 parents 7570f07 + 909437e commit b7627a4

File tree

4 files changed

+4
-24
lines changed

4 files changed

+4
-24
lines changed

src/CodeFormatter/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private static int Main(string[] args)
1919
{
2020
if (args.Length < 1)
2121
{
22-
Console.WriteLine("CodeFormatter <project or solution> [<rule types>] [/file <filename>]");
22+
Console.WriteLine("CodeFormatter <project or solution> [<rule types>] [/file <filename>] [/nocopyright]");
2323
Console.WriteLine(" <rule types> - Rule types to use in addition to the default ones.");
2424
Console.WriteLine(" Use ConvertTests to convert MSTest tests to xUnit.");
2525
Console.WriteLine(" <filename> - Only apply changes to files with specified name.");
@@ -74,7 +74,6 @@ private static async Task RunAsync(string projectOrSolutionPath, IEnumerable<str
7474
{
7575
var workspace = MSBuildWorkspace.Create();
7676
var engine = FormattingEngine.Create(ruleTypes, filenames);
77-
engine.Verbose = true;
7877
if (disableCopright)
7978
{
8079
engine.CopyrightHeader = ImmutableArray<string>.Empty;

src/Microsoft.DotNet.CodeFormatting/FormattingEngineImplementation.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal sealed class FormattingEngineImplementation : IFormattingEngine
2626
private readonly IEnumerable<ILocalSemanticFormattingRule> _localSemanticRules;
2727
private readonly IEnumerable<IGlobalSemanticFormattingRule> _globalSemanticRules;
2828
private readonly Stopwatch _watch = new Stopwatch();
29-
private bool _verbose;
3029

3130
public ImmutableArray<string> CopyrightHeader
3231
{
@@ -40,12 +39,6 @@ public IFormatLogger FormatLogger
4039
set { _options.FormatLogger = value; }
4140
}
4241

43-
public bool Verbose
44-
{
45-
get { return _verbose; }
46-
set { _verbose = value; }
47-
}
48-
4942
[ImportingConstructor]
5043
internal FormattingEngineImplementation(
5144
Options options,
@@ -161,15 +154,7 @@ private void StartDocument()
161154
private void EndDocument(Document document)
162155
{
163156
_watch.Stop();
164-
if (_verbose && _watch.Elapsed.TotalSeconds > 1)
165-
{
166-
FormatLogger.WriteLine();
167-
FormatLogger.WriteLine(" {0} {1} seconds", document.Name, _watch.Elapsed.TotalSeconds);
168-
}
169-
else
170-
{
171-
FormatLogger.Write(".");
172-
}
157+
FormatLogger.WriteLine(" {0} {1} seconds", document.Name, _watch.Elapsed.TotalSeconds);
173158
}
174159

175160
/// <summary>
@@ -202,7 +187,6 @@ private async Task<Solution> RunSyntaxPass(Solution originalSolution, IReadOnlyL
202187
}
203188
}
204189

205-
FormatLogger.WriteLine();
206190
return currentSolution;
207191
}
208192

@@ -224,7 +208,6 @@ private async Task<Solution> RunLocalSemanticPass(Solution solution, IReadOnlyLi
224208
solution = await RunLocalSemanticPass(solution, documentIds, localSemanticRule, cancellationToken);
225209
}
226210

227-
FormatLogger.WriteLine();
228211
return solution;
229212
}
230213

@@ -251,7 +234,6 @@ private async Task<Solution> RunLocalSemanticPass(Solution originalSolution, IRe
251234
}
252235
}
253236

254-
FormatLogger.WriteLine();
255237
return currentSolution;
256238
}
257239

@@ -263,7 +245,6 @@ private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyL
263245
solution = await RunGlobalSemanticPass(solution, documentIds, globalSemanticRule, cancellationToken);
264246
}
265247

266-
FormatLogger.WriteLine();
267248
return solution;
268249
}
269250

@@ -284,7 +265,6 @@ private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyL
284265
EndDocument(document);
285266
}
286267

287-
FormatLogger.WriteLine();
288268
return solution;
289269
}
290270
}

src/Microsoft.DotNet.CodeFormatting/IFormatLogger.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ public void WriteLine(string format, params object[] args)
3131

3232
public void WriteErrorLine(string format, params object[] args)
3333
{
34+
Console.ForegroundColor = ConsoleColor.Red;
3435
Console.Write("Error: ");
3536
Console.WriteLine(format, args);
37+
Console.ResetColor();
3638
}
3739

3840
public void WriteLine()

src/Microsoft.DotNet.CodeFormatting/IFormattingEngine.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace Microsoft.DotNet.CodeFormatting
1313
public interface IFormattingEngine
1414
{
1515
ImmutableArray<string> CopyrightHeader { get; set; }
16-
bool Verbose { get; set; }
1716
Task FormatSolutionAsync(Solution solution, CancellationToken cancellationToken);
1817
Task FormatProjectAsync(Project porject, CancellationToken cancellationToken);
1918
}

0 commit comments

Comments
 (0)