diff --git a/src/Tools/dotnet-format/CodeFormatter.cs b/src/Tools/dotnet-format/CodeFormatter.cs index 9a4cb4b3a2c72111c3b977313d504d4cf1cb6d96..12aafd92084fe934a40c6dc9b70ade77646d5c74 100644 --- a/src/Tools/dotnet-format/CodeFormatter.cs +++ b/src/Tools/dotnet-format/CodeFormatter.cs @@ -61,9 +61,11 @@ public static async Task FormatWorkspaceAsync(ILogger logger, string soluti logger.LogTrace(Resources.Workspace_loaded_in_0_ms, workspaceStopwatch.ElapsedMilliseconds); workspaceStopwatch.Restart(); - exitCode = await FormatFilesInWorkspaceAsync(logger, workspace, projectPath, codingConventionsManager, saveFormattedFiles, cancellationToken).ConfigureAwait(false); + int fileCount; + int filesFormatted; + (exitCode, fileCount, filesFormatted) = await FormatFilesInWorkspaceAsync(logger, workspace, projectPath, codingConventionsManager, saveFormattedFiles, cancellationToken).ConfigureAwait(false); - logger.LogDebug(Resources.Format_complete_in_0_ms, workspaceStopwatch.ElapsedMilliseconds); + logger.LogDebug(Resources.Formatted_0_of_1_files_in_2_ms, filesFormatted, fileCount, workspaceStopwatch.ElapsedMilliseconds); } logger.LogInformation(Resources.Format_complete); @@ -92,11 +94,13 @@ void LogWorkspaceWarnings(object sender, WorkspaceDiagnosticEventArgs args) } } - private static async Task FormatFilesInWorkspaceAsync(ILogger logger, Workspace workspace, string projectPath, ICodingConventionsManager codingConventionsManager, bool saveFormattedFiles, CancellationToken cancellationToken) + private static async Task<(int status, int fileCount, int filesFormatted)> FormatFilesInWorkspaceAsync(ILogger logger, Workspace workspace, string projectPath, ICodingConventionsManager codingConventionsManager, bool saveFormattedFiles, CancellationToken cancellationToken) { var projectIds = workspace.CurrentSolution.ProjectIds.ToImmutableArray(); var optionsApplier = new EditorConfigOptionsApplier(); + var totalFileCount = 0; + var totalFilesFormatted = 0; foreach (var projectId in projectIds) { var project = workspace.CurrentSolution.GetProject(projectId); @@ -114,18 +118,20 @@ private static async Task FormatFilesInWorkspaceAsync(ILogger logger, Works logger.LogInformation(Resources.Formatting_code_files_in_project_0, project.Name); - var formattedSolution = await FormatFilesInProjectAsync(logger, project, codingConventionsManager, optionsApplier, cancellationToken).ConfigureAwait(false); + var (formattedSolution, filesFormatted) = await FormatFilesInProjectAsync(logger, project, codingConventionsManager, optionsApplier, cancellationToken).ConfigureAwait(false); + totalFileCount += project.DocumentIds.Count; + totalFilesFormatted += filesFormatted; if (saveFormattedFiles && !workspace.TryApplyChanges(formattedSolution)) { logger.LogError(Resources.Failed_to_save_formatting_changes); - return 1; + return (1, totalFileCount, totalFilesFormatted); } } - return 0; + return (0, totalFileCount, totalFilesFormatted); } - private static async Task FormatFilesInProjectAsync(ILogger logger, Project project, ICodingConventionsManager codingConventionsManager, EditorConfigOptionsApplier optionsApplier, CancellationToken cancellationToken) + private static async Task<(Solution solution, int filesFormatted)> FormatFilesInProjectAsync(ILogger logger, Project project, ICodingConventionsManager codingConventionsManager, EditorConfigOptionsApplier optionsApplier, CancellationToken cancellationToken) { var isCommentTrivia = project.Language == LanguageNames.CSharp ? IsCSharpCommentTrivia @@ -173,6 +179,7 @@ private static async Task FormatFilesInProjectAsync(ILogger logger, Pr } var formattedSolution = project.Solution; + var filesFormatted = 0; foreach (var (documentId, formatTask) in formattedDocuments) { var text = await formatTask.ConfigureAwait(false); @@ -181,10 +188,11 @@ private static async Task FormatFilesInProjectAsync(ILogger logger, Pr continue; } + filesFormatted++; formattedSolution = formattedSolution.WithDocumentText(documentId, text); } - return formattedSolution; + return (formattedSolution, filesFormatted); } private static Func IsCSharpCommentTrivia = diff --git a/src/Tools/dotnet-format/Properties/launchSettings.json b/src/Tools/dotnet-format/Properties/launchSettings.json index 1b8898185a009803ad63dcc50a1ad2259c56885c..9b923f44b0c2ca4b80c2131be1c9655d98b1c92a 100644 --- a/src/Tools/dotnet-format/Properties/launchSettings.json +++ b/src/Tools/dotnet-format/Properties/launchSettings.json @@ -2,12 +2,12 @@ "profiles": { "dotnet-format (--dry-run)": { "commandName": "Project", - "commandLineArgs": "-w Roslyn.sln --dry-run", + "commandLineArgs": "-w Roslyn.sln -v detailed --dry-run", "workingDirectory": "$(SolutionDir)" }, "dotnet-format": { "commandName": "Project", - "commandLineArgs": "-w Roslyn.sln", + "commandLineArgs": "-w Roslyn.sln -v detailed", "workingDirectory": "$(SolutionDir)" } } diff --git a/src/Tools/dotnet-format/Resources.Designer.cs b/src/Tools/dotnet-format/Resources.Designer.cs index 3262d01cd7731f25cc9e5bb9e33566e26d0b8343..db38828a4894e368a7c90adb507e19d90c262d02 100644 --- a/src/Tools/dotnet-format/Resources.Designer.cs +++ b/src/Tools/dotnet-format/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Tools.CodeFormatter { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -109,20 +109,20 @@ internal class Resources { } /// - /// Looks up a localized string similar to Format complete in {0}ms.. + /// Looks up a localized string similar to Format files, but do not save changes to disk.. /// - internal static string Format_complete_in_0_ms { + internal static string Format_files_but_do_not_save_changes_to_disk { get { - return ResourceManager.GetString("Format_complete_in_0_ms", resourceCulture); + return ResourceManager.GetString("Format_files_but_do_not_save_changes_to_disk", resourceCulture); } } /// - /// Looks up a localized string similar to Format files, but do not save changes to disk.. + /// Looks up a localized string similar to Formatted {0} of {1} files in {2}ms.. /// - internal static string Format_files_but_do_not_save_changes_to_disk { + internal static string Formatted_0_of_1_files_in_2_ms { get { - return ResourceManager.GetString("Format_files_but_do_not_save_changes_to_disk", resourceCulture); + return ResourceManager.GetString("Formatted_0_of_1_files_in_2_ms", resourceCulture); } } diff --git a/src/Tools/dotnet-format/Resources.resx b/src/Tools/dotnet-format/Resources.resx index c51f8f58ed8e1aebbdbdf1f869a4c906716f7a5c..025cb592339bda94592d2c82ec69c5ce0fd7e9e1 100644 --- a/src/Tools/dotnet-format/Resources.resx +++ b/src/Tools/dotnet-format/Resources.resx @@ -156,8 +156,8 @@ Could not format '{0}'. Format currently supports only C# and Visual Basic projects. - - Format complete in {0}ms. + + Formatted {0} of {1} files in {2}ms. Loading workspace. diff --git a/src/Tools/dotnet-format/xlf/Resources.cs.xlf b/src/Tools/dotnet-format/xlf/Resources.cs.xlf index 83423b4a7af1a1e2b2f1ac3c2cc2e8987ad35aab..0ed27b0c8ff1d0e0d4d9652cd42c286059f9ebd8 100644 --- a/src/Tools/dotnet-format/xlf/Resources.cs.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.cs.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.de.xlf b/src/Tools/dotnet-format/xlf/Resources.de.xlf index 4ebd2a3514072d040e64932b9fe46e9b2624a36c..9089c4151cfb50ca288696142d87aebe3bcd2c46 100644 --- a/src/Tools/dotnet-format/xlf/Resources.de.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.de.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.es.xlf b/src/Tools/dotnet-format/xlf/Resources.es.xlf index aa7d26d00a05df80ca241ad93a777284195f3b3d..1593d52774ed5bcd4d11f52e896ea6f13ba08823 100644 --- a/src/Tools/dotnet-format/xlf/Resources.es.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.es.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.fr.xlf b/src/Tools/dotnet-format/xlf/Resources.fr.xlf index 444d9cc75894784856e9ed460fbb7f2628b6fe90..b5bee8e1105bea0e3e9c9606cb8ab8fe949d7c8c 100644 --- a/src/Tools/dotnet-format/xlf/Resources.fr.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.fr.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.it.xlf b/src/Tools/dotnet-format/xlf/Resources.it.xlf index e39482200d928ae90fee933ee2d11b51afdc0846..b864ce104d7837f3717a0d897215388c8ed1dcfe 100644 --- a/src/Tools/dotnet-format/xlf/Resources.it.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.it.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.ja.xlf b/src/Tools/dotnet-format/xlf/Resources.ja.xlf index 8f7a9d2144e572e4f83ac886362683a17f9b0786..fabff53be4978a464d90cd473cb291eb2437344d 100644 --- a/src/Tools/dotnet-format/xlf/Resources.ja.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.ja.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.ko.xlf b/src/Tools/dotnet-format/xlf/Resources.ko.xlf index 89805a1a5782b405a2f6aeaa51959bbc7e864557..c82b0951a69cab0699387173a5746d0f240c7e2f 100644 --- a/src/Tools/dotnet-format/xlf/Resources.ko.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.ko.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.pl.xlf b/src/Tools/dotnet-format/xlf/Resources.pl.xlf index 8241ef50e6745d4d53368de5b5816fa9e4e6c69d..d3c281ad4e5512f87beec5aa0b33544a063841d7 100644 --- a/src/Tools/dotnet-format/xlf/Resources.pl.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.pl.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.pt-BR.xlf b/src/Tools/dotnet-format/xlf/Resources.pt-BR.xlf index 0629b57a56d4e9498b1270b127a69c4943fb6caa..2fac9928c8a11b986a88bbffb79fbb3c205fcb23 100644 --- a/src/Tools/dotnet-format/xlf/Resources.pt-BR.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.pt-BR.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.ru.xlf b/src/Tools/dotnet-format/xlf/Resources.ru.xlf index ce06b4f7517b2b86400cf9cd98162f879cb4b5c5..b4a980af1f5e1a4f51493092a827cb1f39fba0e4 100644 --- a/src/Tools/dotnet-format/xlf/Resources.ru.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.ru.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.tr.xlf b/src/Tools/dotnet-format/xlf/Resources.tr.xlf index 25111acb61104f9c0b2167750e94429467362a94..1bf83b6671b3fe83e406422357b10a0da7bbe5a6 100644 --- a/src/Tools/dotnet-format/xlf/Resources.tr.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.tr.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.zh-Hans.xlf b/src/Tools/dotnet-format/xlf/Resources.zh-Hans.xlf index c68401b3bb3a05eced73b511b23fc12c818c1264..90e5c09b0643c31e409f80a8862d90a0b1a9a857 100644 --- a/src/Tools/dotnet-format/xlf/Resources.zh-Hans.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.zh-Hans.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'. diff --git a/src/Tools/dotnet-format/xlf/Resources.zh-Hant.xlf b/src/Tools/dotnet-format/xlf/Resources.zh-Hant.xlf index 308874239de720dba15419b30f69d507ac5f37ae..f32e59ff725e1cf05338a551f7297ec17f5cc429 100644 --- a/src/Tools/dotnet-format/xlf/Resources.zh-Hant.xlf +++ b/src/Tools/dotnet-format/xlf/Resources.zh-Hant.xlf @@ -27,16 +27,16 @@ Format complete. - - Format complete in {0}ms. - Format complete in {0}ms. - - Format files, but do not save changes to disk. Format files, but do not save changes to disk. + + Formatted {0} of {1} files in {2}ms. + Formatted {0} of {1} files in {2}ms. + + Formatting code file '{0}'. Formatting code file '{0}'.