Ejemplo n.º 1
0
        protected override void Dispose(bool finalize)
        {
            _metadataAsSourceFileService?.CleanupGeneratedFiles();

            this.ClearSolutionData();

            foreach (var document in Documents)
            {
                document.CloseTextView();
            }

            foreach (var document in AdditionalDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in AnalyzerConfigDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in ProjectionDocuments)
            {
                document.CloseTextView();
            }

            if (_backgroundParser != null)
            {
                _backgroundParser.CancelAllParses();
            }

            base.Dispose(finalize);
        }
Ejemplo n.º 2
0
        protected override void Dispose(bool finalize)
        {
            var metadataAsSourceService = ExportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();

            if (metadataAsSourceService != null)
            {
                metadataAsSourceService.CleanupGeneratedFiles();
            }

            this.ClearSolutionData();

            foreach (var document in Documents)
            {
                document.CloseTextView();
            }

            foreach (var document in AdditionalDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in ProjectionDocuments)
            {
                document.CloseTextView();
            }

            var exceptions = ExportProvider.GetExportedValue <TestExtensionErrorHandler>().GetExceptions();

            if (exceptions.Count == 1)
            {
                throw new Xunit.Sdk.AssertException(
                          "A exception was encountered during execution and trapped by the editor:\r\n" +
                          exceptions.Single().Message + "\r\n" +
                          exceptions.Single().StackTrace);
            }
            else if (exceptions.Count > 1)
            {
                throw new Xunit.Sdk.AssertException(
                          "More than one exception was encountered during execution and trapped by the editor:\r\n" +
                          exceptions.First().Message + "\r\n" +
                          exceptions.First().StackTrace);
            }

            if (SynchronizationContext.Current != null)
            {
                Dispatcher.CurrentDispatcher.DoEvents();
            }

            if (_backgroundParser != null)
            {
                _backgroundParser.CancelAllParses();
            }

            base.Dispose(finalize);
        }
Ejemplo n.º 3
0
        protected override void Dispose(bool finalize)
        {
            var metadataAsSourceService = ExportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();

            if (metadataAsSourceService != null)
            {
                metadataAsSourceService.CleanupGeneratedFiles();
            }

            this.ClearSolutionData();

            foreach (var document in Documents)
            {
                document.CloseTextView();
            }

            foreach (var document in AdditionalDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in ProjectionDocuments)
            {
                document.CloseTextView();
            }

            var exceptions = ExportProvider.GetExportedValue <TestExtensionErrorHandler>().GetExceptions();

            if (exceptions.Count == 1)
            {
                throw exceptions.Single();
            }
            else if (exceptions.Count > 1)
            {
                throw new AggregateException(exceptions);
            }

            if (SynchronizationContext.Current != null)
            {
                Dispatcher.CurrentDispatcher.DoEvents();
            }

            if (_backgroundParser != null)
            {
                _backgroundParser.CancelAllParses();
            }

            base.Dispose(finalize);
        }
Ejemplo n.º 4
0
        protected override void Dispose(bool finalize)
        {
            var metadataAsSourceService = ExportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();

            if (metadataAsSourceService != null)
            {
                metadataAsSourceService.CleanupGeneratedFiles();
            }

            this.ClearSolutionData();

            foreach (var document in Documents)
            {
                document.CloseTextView();
            }

            foreach (var document in AdditionalDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in ProjectionDocuments)
            {
                document.CloseTextView();
            }

            if (SynchronizationContext.Current != null)
            {
                Dispatcher.CurrentDispatcher.DoEvents();
            }

            if (_backgroundParser != null)
            {
                _backgroundParser.CancelAllParses();
            }

            base.Dispose(finalize);
        }
Ejemplo n.º 5
0
        protected override void Dispose(bool finalize)
        {
            var metadataAsSourceService = ExportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault();

            if (metadataAsSourceService != null)
            {
                metadataAsSourceService.CleanupGeneratedFiles();
            }

            this.ClearSolutionData();

            foreach (var document in Documents)
            {
                document.CloseTextView();
            }

            foreach (var document in AdditionalDocuments)
            {
                document.CloseTextView();
            }

            foreach (var document in ProjectionDocuments)
            {
                document.CloseTextView();
            }

            var exceptions = Flatten(ExportProvider.GetExportedValue <TestExtensionErrorHandler>().GetExceptions());

            if (exceptions.Count > 0)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.AppendLine(
                    $@"{exceptions.Count} exception(s) were thrown during test.
Note: exceptions may have been thrown by another test running concurrently with
this test.  This can happen with any tests that share the same ExportProvider.
Examining individual exception stacks may help reveal the original test and source 
of the problem.");

                messageBuilder.AppendLine();
                for (int i = 0; i < exceptions.Count; i++)
                {
                    var exception = exceptions[i];
                    messageBuilder.AppendLine($"Exception {i}:");
                    messageBuilder.AppendLine(exception.ToString());
                    messageBuilder.AppendLine();
                }

                var message = messageBuilder.ToString();
                if (exceptions.Count == 1)
                {
                    throw new Exception(message, exceptions[0]);
                }
                else
                {
                    throw new AggregateException(message, exceptions);
                }
            }

            if (SynchronizationContext.Current != null)
            {
                Dispatcher.CurrentDispatcher.DoEvents();
            }

            if (_backgroundParser != null)
            {
                _backgroundParser.CancelAllParses();
            }

            base.Dispose(finalize);
        }