Example #1
0
        private IEnumerable <DiagnosticData> GetDiagnosticsToFix(Func <Project, bool> shouldFixInProject, bool selectedEntriesOnly, bool isAddSuppression)
        {
            var diagnosticsToFix = SpecializedCollections.EmptyEnumerable <DiagnosticData>();
            Action <CancellationToken> computeDiagnosticsToFix = cancellationToken =>
            {
                // If we are fixing selected diagnostics in error list, then get the diagnostics from error list entry snapshots.
                // Otherwise, get all diagnostics from the diagnostic service.
                var diagnosticsToFixTask = selectedEntriesOnly ?
                                           _suppressionStateService.GetSelectedItemsAsync(isAddSuppression, cancellationToken) :
                                           GetAllDiagnosticsAsync(shouldFixInProject, cancellationToken);

                diagnosticsToFix = diagnosticsToFixTask.WaitAndGetResult(cancellationToken);
            };

            var title             = GetFixTitle(isAddSuppression);
            var waitDialogMessage = GetWaitDialogMessage(isAddSuppression);
            var result            = InvokeWithWaitDialog(computeDiagnosticsToFix, title, waitDialogMessage);

            // Bail out if the user cancelled.
            if (result == WaitIndicatorResult.Canceled)
            {
                return(null);
            }

            return(diagnosticsToFix);
        }
Example #2
0
        private IEnumerable <DiagnosticData>?GetDiagnosticsToFix(Func <Project, bool> shouldFixInProject, bool selectedEntriesOnly, bool isAddSuppression)
        {
            var diagnosticsToFix = ImmutableHashSet <DiagnosticData> .Empty;

            void computeDiagnosticsToFix(IUIThreadOperationContext context)
            {
                var cancellationToken = context.UserCancellationToken;

                // If we are fixing selected diagnostics in error list, then get the diagnostics from error list entry snapshots.
                // Otherwise, get all diagnostics from the diagnostic service.
                var diagnosticsToFixTask = selectedEntriesOnly ?
                                           _suppressionStateService.GetSelectedItemsAsync(isAddSuppression, cancellationToken) :
                                           GetAllBuildDiagnosticsAsync(shouldFixInProject, cancellationToken);

                diagnosticsToFix = diagnosticsToFixTask.WaitAndGetResult(cancellationToken).ToImmutableHashSet();
            }

            var title             = GetFixTitle(isAddSuppression);
            var waitDialogMessage = GetWaitDialogMessage(isAddSuppression);
            var result            = InvokeWithWaitDialog(computeDiagnosticsToFix, title, waitDialogMessage);

            // Bail out if the user cancelled.
            if (result == UIThreadOperationStatus.Canceled)
            {
                return(null);
            }

            return(diagnosticsToFix);
        }
Example #3
0
        private IEnumerable <DiagnosticData> GetDiagnosticsToFix(bool selectedEntriesOnly, bool isAddSuppression)
        {
            var diagnosticsToFix = ImmutableHashSet <DiagnosticData> .Empty;
            Action <IWaitContext> computeDiagnosticsToFix = context =>
            {
                var cancellationToken = context.CancellationToken;

                // If we are fixing selected diagnostics in error list, then get the diagnostics from error list entry snapshots.
                // Otherwise, get all diagnostics from the diagnostic service.
                var diagnosticsToFixTask = selectedEntriesOnly
                    ? _suppressionStateService.GetSelectedItemsAsync(isAddSuppression, cancellationToken)
                    : GetAllBuildDiagnosticsAsync(cancellationToken);

                diagnosticsToFix = diagnosticsToFixTask.WaitAndGetResult(cancellationToken).ToImmutableHashSet();
            };

            var title             = GetFixTitle(isAddSuppression);
            var waitDialogMessage = GetWaitDialogMessage(isAddSuppression);
            var result            = InvokeWithWaitDialog(computeDiagnosticsToFix, title, waitDialogMessage);

            // Bail out if the user cancelled.
            if (result == WaitIndicatorResult.Canceled)
            {
                return(null);
            }

            return(diagnosticsToFix);
        }