From 76298d4be02ff41f909ddd9383d5db85a0ac6b42 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 May 2024 16:15:09 -0700 Subject: [PATCH 1/2] Simplify progress scope code --- .../AbstractSuppressionBatchFixAllProvider.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionBatchFixAllProvider.cs b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionBatchFixAllProvider.cs index fd7c338bbf804..7fb1b6b5b54ab 100644 --- a/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionBatchFixAllProvider.cs +++ b/src/Features/Core/Portable/CodeFixes/Suppression/AbstractSuppressionBatchFixAllProvider.cs @@ -96,16 +96,11 @@ internal abstract class AbstractSuppressionBatchFixAllProvider : FixAllProvider source, produceItems: static async (tuple, callback, args, cancellationToken) => { + using var _ = args.progressTracker.ItemCompletedScope(); + var (document, diagnosticsToFix) = tuple; - try - { - await args.@this.AddDocumentFixesAsync( - document, diagnosticsToFix, callback, args.fixAllState, cancellationToken).ConfigureAwait(false); - } - finally - { - args.progressTracker.ItemCompleted(); - } + await args.@this.AddDocumentFixesAsync( + document, diagnosticsToFix, callback, args.fixAllState, cancellationToken).ConfigureAwait(false); }, args: (@this: this, fixAllState, progressTracker), cancellationToken).ConfigureAwait(false); From a65103afaa5b5693a27c02efd77a4afffb42d693 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 May 2024 16:17:00 -0700 Subject: [PATCH 2/2] Another case --- .../CodeFixes/FixAllOccurrences/FixAllContextHelper.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs index faa52b4fd783e..834c0d8f05cdb 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs @@ -79,14 +79,8 @@ public static async Task { - try - { - callback(await args.fixAllContext.GetAllDiagnosticsAsync(projectToFix).ConfigureAwait(false)); - } - finally - { - args.progressTracker.ItemCompleted(); - } + using var _ = args.progressTracker.ItemCompletedScope(); + callback(await args.fixAllContext.GetAllDiagnosticsAsync(projectToFix).ConfigureAwait(false)); }, consumeItems: static async (results, args, cancellationToken) => {