Skip to content

Commit 0caa94c

Browse files
committed
Filter out project early if it doesn't have any formattable documents
Improves the runtime in large solutions when a small number of files is included (`--include`). This is a common use-case for developers to lint/format only modified files in their branch. In a solution with about 80 projects, this improves the runtime by about 50% when `--include SomeProject/SomeFile.cs` is specified. Related issues: #1378 and #757
1 parent e473b1d commit 0caa94c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Analyzers/AnalyzerFormatter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ internal static async Task<ImmutableDictionary<ProjectId, ImmutableArray<Diagnos
283283
{
284284
continue;
285285
}
286+
// Skip if the project does not contain any of the formattable paths.
287+
if (!project.Documents.Any(d => d.FilePath is not null && formattablePaths.Contains(d.FilePath)))
288+
{
289+
continue;
290+
}
286291

287292
var analyzers = ImmutableArray.CreateBuilder<DiagnosticAnalyzer>();
288293

0 commit comments

Comments
 (0)