Skip to content

Commit

Permalink
Max 1000 iterations in fix all.
Browse files Browse the repository at this point in the history
Fix #264
  • Loading branch information
JohanLarsson committed May 6, 2022
1 parent 9ab98d7 commit 28ceeea
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Gu.Roslyn.Asserts/Fix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,18 @@ await ApplyAsync(solution, fix, fixable, fixTitle, cancellationToken).ConfigureA
/// <returns>The fixed solution or the same instance if no fix.</returns>
internal static async Task<Solution> ApplyAllFixableScopeByScopeAsync(Solution solution, DiagnosticAnalyzer analyzer, CodeFixProvider fix, FixAllScope scope, string? fixTitle = null, CancellationToken cancellationToken = default)
{
var n = 0;
while (await ApplyNext(solution, analyzer, fix, scope, fixTitle, cancellationToken).ConfigureAwait(false) is { } fixedSolution)
{
// Keeping it simple allowing 1000 retries
// This means the error case is slow but normal case fast
// Using a set with diagnostics nicer but means slight perf penalty for the happy path.
if (n > 1_000)
{
return solution;
}

n++;
solution = fixedSolution;
}

Expand Down

0 comments on commit 28ceeea

Please sign in to comment.