diff --git a/README.md b/README.md index 5fcdde9fc5..ab520657c1 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Options: --dry-run Format files, but do not save changes to disk. --check Terminates with a non-zero exit code if any files were formatted. --files A comma separated list of relative file paths to format. All files are formatted if empty. + --exclude A comma separated list of relative file or folder paths to exclude from formatting. --version Display version information --report Writes a json file to the given directory. Defaults to 'format-report.json' if no filename given. ``` diff --git a/src/CodeFormatter.cs b/src/CodeFormatter.cs index d116c89d37..e8de77f34e 100644 --- a/src/CodeFormatter.cs +++ b/src/CodeFormatter.cs @@ -34,7 +34,7 @@ public static async Task FormatWorkspaceAsync( ILogger logger, CancellationToken cancellationToken) { - var (workspaceFilePath, workspaceType, logLevel, saveFormattedFiles, _, filesToFormat, reportPath) = options; + var (workspaceFilePath, workspaceType, logLevel, saveFormattedFiles, _, filesToFormat, filesToIgnore, reportPath) = options; var logWorkspaceWarnings = logLevel == LogLevel.Trace; logger.LogInformation(string.Format(Resources.Formatting_code_files_in_workspace_0, workspaceFilePath)); @@ -60,7 +60,7 @@ public static async Task FormatWorkspaceAsync( logger.LogTrace(Resources.Determining_formattable_files); var (fileCount, formatableFiles) = await DetermineFormattableFiles( - solution, projectPath, filesToFormat, logger, cancellationToken).ConfigureAwait(false); + solution, projectPath, filesToFormat, filesToIgnore, logger, cancellationToken).ConfigureAwait(false); var determineFilesMS = workspaceStopwatch.ElapsedMilliseconds - loadWorkspaceMS; logger.LogTrace(Resources.Complete_in_0_ms, determineFilesMS); @@ -242,6 +242,7 @@ private static async Task RunCodeFormattersAsync( Solution solution, string projectPath, ImmutableHashSet filesToFormat, + ImmutableHashSet filesToIgnore, ILogger logger, CancellationToken cancellationToken) { @@ -271,7 +272,7 @@ private static async Task RunCodeFormattersAsync( // Get project documents and options with .editorconfig settings applied. var getProjectDocuments = project.DocumentIds.Select(documentId => GetDocumentAndOptions( - project, documentId, filesToFormat, codingConventionsManager, optionsApplier, cancellationToken)); + project, documentId, filesToFormat, filesToIgnore, codingConventionsManager, optionsApplier, cancellationToken)); getDocumentsAndOptions.AddRange(getProjectDocuments); } @@ -310,25 +311,14 @@ private static async Task RunCodeFormattersAsync( Project project, DocumentId documentId, ImmutableHashSet filesToFormat, + ImmutableHashSet filesToIgnore, ICodingConventionsManager codingConventionsManager, EditorConfigOptionsApplier optionsApplier, CancellationToken cancellationToken) { var document = project.Solution.GetDocument(documentId); - // If a files list was passed in, then ignore files not present in the list. - if (!filesToFormat.IsEmpty && !filesToFormat.Contains(document.FilePath)) - { - return (null, null, null, false); - } - - if (!document.SupportsSyntaxTree) - { - return (null, null, null, false); - } - - // Ignore generated code files. - if (await GeneratedCodeUtilities.IsGeneratedCodeAsync(document, cancellationToken).ConfigureAwait(false)) + if (await ShouldIgnoreDocument(document, filesToFormat, filesToIgnore, cancellationToken)) { return (null, null, null, false); } @@ -347,5 +337,36 @@ private static async Task RunCodeFormattersAsync( options = optionsApplier.ApplyConventions(options, context.CurrentConventions, project.Language); return (document, options, context.CurrentConventions, true); } + + private static async Task ShouldIgnoreDocument( + Document document, + ImmutableHashSet filesToFormat, + ImmutableHashSet filesToIgnore, + CancellationToken cancellationToken) + { + if (!filesToFormat.IsEmpty && !filesToFormat.Contains(document.FilePath)) + { + // If a files list was passed in, then ignore files not present in the list. + return true; + } + else if (!document.SupportsSyntaxTree) + { + return true; + } + else if (await GeneratedCodeUtilities.IsGeneratedCodeAsync(document, cancellationToken).ConfigureAwait(false)) + { + // Ignore generated code files. + return true; + } + else if (!filesToIgnore.IsEmpty && filesToIgnore.Any(f => document.FilePath.StartsWith(f, StringComparison.OrdinalIgnoreCase))) + { + // Ignore file in, or under a folder in the list to exclude + return true; + } + else + { + return false; + } + } } } diff --git a/src/FormatOptions.cs b/src/FormatOptions.cs index ec2d2a8fbd..cee32f81c0 100644 --- a/src/FormatOptions.cs +++ b/src/FormatOptions.cs @@ -13,6 +13,7 @@ internal class FormatOptions public bool SaveFormattedFiles { get; } public bool ChangesAreErrors { get; } public ImmutableHashSet FilesToFormat { get; } + public ImmutableHashSet FilesToIgnore { get; } public string ReportPath { get; } public FormatOptions( @@ -22,6 +23,7 @@ public FormatOptions( bool saveFormattedFiles, bool changesAreErrors, ImmutableHashSet filesToFormat, + ImmutableHashSet filesToIgnore, string reportPath) { WorkspaceFilePath = workspaceFilePath; @@ -30,6 +32,7 @@ public FormatOptions( SaveFormattedFiles = saveFormattedFiles; ChangesAreErrors = changesAreErrors; FilesToFormat = filesToFormat; + FilesToIgnore = filesToIgnore; ReportPath = reportPath; } @@ -40,6 +43,7 @@ public void Deconstruct( out bool saveFormattedFiles, out bool changesAreErrors, out ImmutableHashSet filesToFormat, + out ImmutableHashSet filesToIgnore, out string reportPath) { workspaceFilePath = WorkspaceFilePath; @@ -48,6 +52,7 @@ public void Deconstruct( saveFormattedFiles = SaveFormattedFiles; changesAreErrors = ChangesAreErrors; filesToFormat = FilesToFormat; + filesToIgnore = FilesToIgnore; reportPath = ReportPath; } } diff --git a/src/Program.cs b/src/Program.cs index d3bc20acab..c1e8307371 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -36,6 +36,7 @@ private static async Task Main(string[] args) .AddOption(new Option(new[] { "--dry-run" }, Resources.Format_files_but_do_not_save_changes_to_disk, new Argument())) .AddOption(new Option(new[] { "--check" }, Resources.Terminate_with_a_non_zero_exit_code_if_any_files_were_formatted, new Argument())) .AddOption(new Option(new[] { "--files" }, Resources.A_comma_separated_list_of_relative_file_paths_to_format_All_files_are_formatted_if_empty, new Argument(() => null))) + .AddOption(new Option(new[] { "--exclude" }, Resources.A_comma_separated_list_of_relative_file_or_folder_paths_to_exclude_from_formatting, new Argument(() => null))) .AddOption(new Option(new[] { "--report" }, Resources.Accepts_a_file_path_which_if_provided_will_produce_a_format_report_json_file_in_the_given_directory, new Argument(() => null))) .UseVersionOption() .Build(); @@ -43,7 +44,7 @@ private static async Task Main(string[] args) return await parser.InvokeAsync(args).ConfigureAwait(false); } - public static async Task Run(string folder, string workspace, string verbosity, bool dryRun, bool check, string files, string report, IConsole console = null) + public static async Task Run(string folder, string workspace, string verbosity, bool dryRun, bool check, string files, string exclude, string report, IConsole console = null) { // Setup logging. var serviceCollection = new ServiceCollection(); @@ -101,7 +102,8 @@ public static async Task Run(string folder, string workspace, string verbos Environment.CurrentDirectory = workspaceDirectory; - var filesToFormat = GetFilesToFormat(files, folder); + var filesToFormat = GetFiles(files, folder); + var filesToIgnore = GetFiles(exclude, folder); // Since we are running as a dotnet tool we should be able to find an instance of // MSBuild in a .NET Core SDK. @@ -122,6 +124,7 @@ public static async Task Run(string folder, string workspace, string verbos saveFormattedFiles: !dryRun, changesAreErrors: check, filesToFormat, + filesToIgnore, reportPath: report); var formatResult = await CodeFormatter.FormatWorkspaceAsync( @@ -192,7 +195,7 @@ private static void ConfigureServices(ServiceCollection serviceCollection, ICons /// /// Converts a comma-separated list of relative file paths to a hashmap of full file paths. /// - internal static ImmutableHashSet GetFilesToFormat(string files, string folder) + internal static ImmutableHashSet GetFiles(string files, string folder) { if (string.IsNullOrEmpty(files)) { diff --git a/src/Resources.resx b/src/Resources.resx index 7a7a5a25b4..697faa0575 100644 --- a/src/Resources.resx +++ b/src/Resources.resx @@ -216,4 +216,7 @@ Writing formatting report to: '{0}'. + + A comma separated list of relative file or folder paths to exclude from formatting + \ No newline at end of file diff --git a/src/xlf/Resources.cs.xlf b/src/xlf/Resources.cs.xlf index a69cba18b9..cb119b3574 100644 --- a/src/xlf/Resources.cs.xlf +++ b/src/xlf/Resources.cs.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.de.xlf b/src/xlf/Resources.de.xlf index eebd3920c3..15076bf91e 100644 --- a/src/xlf/Resources.de.xlf +++ b/src/xlf/Resources.de.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.es.xlf b/src/xlf/Resources.es.xlf index ba69ba3c3d..ee02effb0d 100644 --- a/src/xlf/Resources.es.xlf +++ b/src/xlf/Resources.es.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.fr.xlf b/src/xlf/Resources.fr.xlf index 5524303813..5d21567927 100644 --- a/src/xlf/Resources.fr.xlf +++ b/src/xlf/Resources.fr.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.it.xlf b/src/xlf/Resources.it.xlf index d4344edda3..08f6bc534b 100644 --- a/src/xlf/Resources.it.xlf +++ b/src/xlf/Resources.it.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.ja.xlf b/src/xlf/Resources.ja.xlf index 52fec6f7e3..b753caf128 100644 --- a/src/xlf/Resources.ja.xlf +++ b/src/xlf/Resources.ja.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.ko.xlf b/src/xlf/Resources.ko.xlf index d9152c013e..ff7ed4adb2 100644 --- a/src/xlf/Resources.ko.xlf +++ b/src/xlf/Resources.ko.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.pl.xlf b/src/xlf/Resources.pl.xlf index 078cca4c95..8088e93b18 100644 --- a/src/xlf/Resources.pl.xlf +++ b/src/xlf/Resources.pl.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.pt-BR.xlf b/src/xlf/Resources.pt-BR.xlf index 6bf7888b1f..f3f7f59b3e 100644 --- a/src/xlf/Resources.pt-BR.xlf +++ b/src/xlf/Resources.pt-BR.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.ru.xlf b/src/xlf/Resources.ru.xlf index 5c5d2c581f..3e44041d7a 100644 --- a/src/xlf/Resources.ru.xlf +++ b/src/xlf/Resources.ru.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.tr.xlf b/src/xlf/Resources.tr.xlf index 5c9cc06534..5f759d0f74 100644 --- a/src/xlf/Resources.tr.xlf +++ b/src/xlf/Resources.tr.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.zh-Hans.xlf b/src/xlf/Resources.zh-Hans.xlf index 01656d5dd0..3be21a3fe0 100644 --- a/src/xlf/Resources.zh-Hans.xlf +++ b/src/xlf/Resources.zh-Hans.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/src/xlf/Resources.zh-Hant.xlf b/src/xlf/Resources.zh-Hant.xlf index 592725dae2..0574ba5e5c 100644 --- a/src/xlf/Resources.zh-Hant.xlf +++ b/src/xlf/Resources.zh-Hant.xlf @@ -2,6 +2,11 @@ + + A comma separated list of relative file or folder paths to exclude from formatting + A comma separated list of relative file or folder paths to exclude from formatting + + A comma separated list of relative file paths to format. All files are formatted if empty. A comma separated list of relative file paths to format. All files are formatted if empty. diff --git a/tests/CodeFormatterTests.cs b/tests/CodeFormatterTests.cs index 1bd6acf413..465a562b9c 100644 --- a/tests/CodeFormatterTests.cs +++ b/tests/CodeFormatterTests.cs @@ -29,7 +29,7 @@ public class CodeFormatterTests : IClassFixture, IClassFixture EmptyFilesToFormat => Array.Empty(); + private static IEnumerable EmptyFilesList => Array.Empty(); private Regex FindFormattingLogLine => new Regex(@"((.*)\(\d+,\d+\): (.*))\r|((.*)\(\d+,\d+\): (.*))"); @@ -44,7 +44,8 @@ public async Task NoFilesFormattedInFormattedProject() { await TestFormatWorkspaceAsync( FormattedProjectFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 0, expectedFileCount: 3); @@ -55,7 +56,8 @@ public async Task NoFilesFormattedInFormattedSolution() { await TestFormatWorkspaceAsync( FormattedSolutionFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 0, expectedFileCount: 3); @@ -66,7 +68,8 @@ public async Task FilesFormattedInUnformattedProject() { await TestFormatWorkspaceAsync( UnformattedProjectFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 2, expectedFileCount: 5); @@ -77,7 +80,8 @@ public async Task FilesFormattedInUnformattedSolution() { await TestFormatWorkspaceAsync( UnformattedSolutionFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 2, expectedFileCount: 5); @@ -90,7 +94,8 @@ public async Task FilesFormattedInUnformattedProjectFolder() // Since the code files are beneath the project folder, files are found and formatted. await TestFormatWorkspaceAsync( Path.GetDirectoryName(UnformattedProjectFilePath), - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 2, expectedFileCount: 3); @@ -102,7 +107,8 @@ public async Task NoFilesFormattedInUnformattedSolutionFolder() // Since the code files are outside the solution folder, no files are found or formatted. await TestFormatWorkspaceAsync( Path.GetDirectoryName(UnformattedSolutionFilePath), - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 0, expectedFileCount: 0); @@ -113,7 +119,8 @@ public async Task FSharpProjectsDoNotCreateException() { var log = await TestFormatWorkspaceAsync( FSharpProjectFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 1, expectedFilesFormatted: 0, expectedFileCount: 0); @@ -133,6 +140,7 @@ public async Task OnlyFormatFilesFromList() await TestFormatWorkspaceAsync( UnformattedProjectFilePath, filesToFormat, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 1, expectedFileCount: 5); @@ -146,6 +154,7 @@ public async Task NoFilesFormattedWhenNotInList() await TestFormatWorkspaceAsync( UnformattedProjectFilePath, files, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 0, expectedFileCount: 5); @@ -159,6 +168,7 @@ public async Task OnlyLogFormattedFiles() var log = await TestFormatWorkspaceAsync( UnformattedSolutionFilePath, files, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 1, expectedFileCount: 5); @@ -175,7 +185,8 @@ public async Task FormatLocationsLoggedInUnformattedProject() { var log = await TestFormatWorkspaceAsync( UnformattedProjectFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 2, expectedFileCount: 5); @@ -224,7 +235,8 @@ public async Task FormatLocationsNotLoggedInFormattedProject() { var log = await TestFormatWorkspaceAsync( FormattedProjectFilePath, - EmptyFilesToFormat, + files: EmptyFilesList, + exclude: EmptyFilesList, expectedExitCode: 0, expectedFilesFormatted: 0, expectedFileCount: 3); @@ -235,7 +247,67 @@ public async Task FormatLocationsNotLoggedInFormattedProject() Assert.Empty(formatLocations); } - public async Task TestFormatWorkspaceAsync(string workspaceFilePath, IEnumerable files, int expectedExitCode, int expectedFilesFormatted, int expectedFileCount) + [Fact] + public async Task LogFilesThatDontMatchExclude() + { + var files = new[] { UnformattedProgramFilePath }; + var exclude = new[] { FormattedProjectPath }; + + var log = await TestFormatWorkspaceAsync( + UnformattedSolutionFilePath, + files, + exclude: EmptyFilesList, + expectedExitCode: 0, + expectedFilesFormatted: 1, + expectedFileCount: 5); + + var pattern = string.Format(Resources.Formatted_code_file_0, @"(.*)"); + var match = new Regex(pattern, RegexOptions.Multiline).Match(log); + + Assert.True(match.Success, log); + Assert.Equal("Program.cs", match.Groups[1].Value); + } + + [Fact] + public async Task IgnoreFileWhenListedInExcludeList() + { + var files = new[] { UnformattedProgramFilePath }; + + var log = await TestFormatWorkspaceAsync( + UnformattedSolutionFilePath, + files: files, + exclude: files, + expectedExitCode: 0, + expectedFilesFormatted: 0, + expectedFileCount: 5); + + var pattern = string.Format(Resources.Formatted_code_file_0, @"(.*)"); + var match = new Regex(pattern, RegexOptions.Multiline).Match(log); + + Assert.False(match.Success, log); + } + + [Fact] + public async Task IgnoreFileWhenContainingFolderListedInExcludeList() + { + var files = new[] { UnformattedProgramFilePath }; + var exclude = new[] { UnformattedProjectPath }; + + var log = await TestFormatWorkspaceAsync( + UnformattedSolutionFilePath, + files: files, + exclude: exclude, + expectedExitCode: 0, + expectedFilesFormatted: 0, + expectedFileCount: 5); + + var pattern = string.Format(Resources.Formatted_code_file_0, @"(.*)"); + var match = new Regex(pattern, RegexOptions.Multiline).Match(log); + + Assert.False(match.Success, log); + } + + public async Task TestFormatWorkspaceAsync(string workspaceFilePath, IEnumerable files, IEnumerable exclude, int expectedExitCode, int expectedFilesFormatted, int expectedFileCount) { var workspacePath = Path.GetFullPath(workspaceFilePath); @@ -252,6 +324,7 @@ public async Task TestFormatWorkspaceAsync(string workspaceFilePath, IEn } var filesToFormat = files.Select(Path.GetFullPath).ToImmutableHashSet(StringComparer.OrdinalIgnoreCase); + var filesToIgnore = exclude.Select(Path.GetFullPath).ToImmutableHashSet(StringComparer.OrdinalIgnoreCase); var logger = new TestLogger(); var formatOptions = new FormatOptions( @@ -261,6 +334,7 @@ public async Task TestFormatWorkspaceAsync(string workspaceFilePath, IEn saveFormattedFiles: false, changesAreErrors: false, filesToFormat, + filesToIgnore, reportPath: string.Empty); var formatResult = await CodeFormatter.FormatWorkspaceAsync(formatOptions, logger, CancellationToken.None); diff --git a/tests/Formatters/AbstractFormatterTests.cs b/tests/Formatters/AbstractFormatterTests.cs index 41d52a279d..b069f0e799 100644 --- a/tests/Formatters/AbstractFormatterTests.cs +++ b/tests/Formatters/AbstractFormatterTests.cs @@ -92,6 +92,7 @@ private protected async Task TestAsync(string testCode, string expec saveFormattedFiles: false, changesAreErrors: false, filesToFormat: ImmutableHashSet.Create(document.FilePath), + filesToIgnore: ImmutableHashSet.Create(), reportPath: string.Empty); var filesToFormat = await GetOnlyFileToFormatAsync(solution, editorConfig); diff --git a/tests/Formatters/FormattedFilesTests.cs b/tests/Formatters/FormattedFilesTests.cs index cd50fac8d2..782209fa1d 100644 --- a/tests/Formatters/FormattedFilesTests.cs +++ b/tests/Formatters/FormattedFilesTests.cs @@ -56,6 +56,7 @@ private async Task> TestFormattedFiles(string testCode) saveFormattedFiles: false, changesAreErrors: false, filesToFormat: ImmutableHashSet.Create(document.FilePath), + filesToIgnore: ImmutableHashSet.Create(), reportPath: string.Empty); var filesToFormat = await GetOnlyFileToFormatAsync(solution, editorConfig); diff --git a/tests/ProgramTests.cs b/tests/ProgramTests.cs index 2eb7ea2495..9808d1201b 100644 --- a/tests/ProgramTests.cs +++ b/tests/ProgramTests.cs @@ -38,10 +38,10 @@ public void ExitCodeIsSameWithoutCheck() public void FilesFormattedDirectorySeparatorInsensitive() { var filePath = $"other_items{Path.DirectorySeparatorChar}OtherClass.cs"; - var files = Program.GetFilesToFormat(filePath, folder: null); + var files = Program.GetFiles(filePath, folder: null); var filePathAlt = $"other_items{Path.AltDirectorySeparatorChar}OtherClass.cs"; - var filesAlt = Program.GetFilesToFormat(filePathAlt, folder: null); + var filesAlt = Program.GetFiles(filePathAlt, folder: null); Assert.True(files.IsSubsetOf(filesAlt)); }