Пример #1
0
        private void OnAnalysisRequested(object sender, AnalysisRequestEventArgs args)
        {
            // Handle notification from the single file monitor that the settings file has changed.

            // Re-analysis could take multiple seconds so it's possible that we'll get another
            // file change notification before the re-analysis has completed.
            // If that happens we'll cancel the current re-analysis and start another one.
            lock (reanalysisLockObject)
            {
                reanalysisJob?.Cancel();
                reanalysisProgressHandler?.Dispose();

                var filteredIssueTrackers = FilterIssuesTrackersByPath(this.issueTrackers, args.FilePaths);

                var operations = filteredIssueTrackers
                                 .Select <IIssueTracker, Action>(it => () => it.RequestAnalysis(args.Options))
                                 .ToArray(); // create a fixed list - the user could close a file before the reanalysis completes which would cause the enumeration to change

                reanalysisProgressHandler = new StatusBarReanalysisProgressHandler(vsStatusBar, logger);

                var message = string.Format(CultureInfo.CurrentCulture, Strings.JobRunner_JobDescription_ReaanalyzeDocs, operations.Length);
                reanalysisJob = CancellableJobRunner.Start(message, operations,
                                                           reanalysisProgressHandler, logger);
            }
        }
Пример #2
0
        public void OneListener_EventIsRaised()
        {
            var logger      = new TestLogger();
            var testSubject = new AnalysisRequester(logger);

            bool   eventRaised  = false;
            object actualSender = null;
            AnalysisRequestEventArgs actualEventArgs = null;

            testSubject.AnalysisRequested += (s, args) =>
            {
                // Don't assert here - one a background thread,
                // and the exception will be caught and suppressed.

                actualSender    = s;
                actualEventArgs = args;
                eventRaised     = true;
            };


            var inputOptions = new Mock <IAnalyzerOptions>().Object;

            // Act
            testSubject.RequestAnalysis(inputOptions, "file1", "c:\\aaa\\bbb.cs");

            // Assert
            eventRaised.Should().BeTrue();
            actualSender.Should().Be(testSubject);
            actualEventArgs.Should().NotBeNull();
            actualEventArgs.Options.Should().BeSameAs(inputOptions);
            actualEventArgs.FilePaths.Should().BeEquivalentTo("file1", "c:\\aaa\\bbb.cs");
        }
Пример #3
0
 public void RequestAnalysis(IAnalyzerOptions analyzerOptions, params string[] filePaths)
 {
     try
     {
         var args = new AnalysisRequestEventArgs(analyzerOptions, filePaths);
         AnalysisRequested?.Invoke(this, args);
     }
     catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex))
     {
         logger.WriteLine(Analysis.AnalysisStrings.Requester_Error, ex);
     }
 }