public static RenameTrackingTestState Create(
            string markup,
            string languageName,
            bool onBeforeGlobalSymbolRenamedReturnValue = true,
            bool onAfterGlobalSymbolRenamedReturnValue  = true)
        {
            var workspace = CreateTestWorkspace(markup, languageName, EditorServicesUtil.CreateExportProvider());

            return(new RenameTrackingTestState(workspace, languageName, onBeforeGlobalSymbolRenamedReturnValue, onAfterGlobalSymbolRenamedReturnValue));
        }
Example #2
0
            public WorkCoordinatorWorkspace(string workspaceKind = null, bool disablePartialSolutions = true)
                : base(EditorServicesUtil.CreateExportProvider(), workspaceKind, disablePartialSolutions)
            {
                _workspaceWaiter       = GetListenerProvider(ExportProvider).GetWaiter(FeatureAttribute.Workspace);
                _solutionCrawlerWaiter = GetListenerProvider(ExportProvider).GetWaiter(FeatureAttribute.SolutionCrawler);

                Assert.False(_workspaceWaiter.HasPendingWork);
                Assert.False(_solutionCrawlerWaiter.HasPendingWork);

                SetOptions(this);
            }
            public WorkCoordinatorWorkspace(string workspaceKind = null, bool disablePartialSolutions = true)
                : base(EditorServicesUtil.CreateExportProvider(), workspaceKind, disablePartialSolutions)
            {
                _workspaceWaiter       = GetListeners(ExportProvider).First(l => l.Metadata.FeatureName == FeatureAttribute.Workspace).Value as IAsynchronousOperationWaiter;
                _solutionCrawlerWaiter = GetListeners(ExportProvider).First(l => l.Metadata.FeatureName == FeatureAttribute.SolutionCrawler).Value as IAsynchronousOperationWaiter;

                Assert.False(_workspaceWaiter.HasPendingWork);
                Assert.False(_solutionCrawlerWaiter.HasPendingWork);

                SetOptions(this);
            }
Example #4
0
        public static async Task <RenameTrackingTestState> CreateFromWorkspaceXmlAsync(
            string workspaceXml,
            string languageName,
            bool onBeforeGlobalSymbolRenamedReturnValue = true,
            bool onAfterGlobalSymbolRenamedReturnValue  = true)
        {
            var workspace = await TestWorkspace.CreateAsync(
                workspaceXml,
                exportProvider : EditorServicesUtil.CreateExportProvider());

            return(new RenameTrackingTestState(workspace, languageName, onBeforeGlobalSymbolRenamedReturnValue, onAfterGlobalSymbolRenamedReturnValue));
        }
Example #5
0
        public async Task TestPreviewDiagnosticTaggerInPreviewPane()
        {
            using (var workspace = TestWorkspace.CreateCSharp("class { }", exportProvider: EditorServicesUtil.CreateExportProvider()))
            {
                // set up listener to wait until diagnostic finish running
                var diagnosticService = workspace.ExportProvider.GetExportedValue <IDiagnosticService>();

                var hostDocument = workspace.Projects.First().Documents.First();

                // make a change to remove squiggle
                var oldDocument = workspace.CurrentSolution.GetDocument(hostDocument.Id);
                var oldText     = oldDocument.GetTextAsync().Result;

                var newDocument = oldDocument.WithText(oldText.WithChanges(new TextChange(new TextSpan(0, oldText.Length), "class C { }")));

                // create a diff view
                WpfTestCase.RequireWpfFact($"{nameof(TestPreviewDiagnosticTaggerInPreviewPane)} creates a {nameof(DifferenceViewerPreview)}");

                var previewFactoryService = workspace.ExportProvider.GetExportedValue <IPreviewFactoryService>();
                using (var diffView = (DifferenceViewerPreview)(await previewFactoryService.CreateChangedDocumentPreviewViewAsync(oldDocument, newDocument, CancellationToken.None)))
                {
                    var foregroundService = workspace.GetService <IForegroundNotificationService>();

                    var listenerProvider = workspace.ExportProvider.GetExportedValue <AsynchronousOperationListenerProvider>();

                    // set up tagger for both buffers
                    var leftBuffer   = diffView.Viewer.LeftView.BufferGraph.GetTextBuffers(t => t.ContentType.IsOfType(ContentTypeNames.CSharpContentType)).First();
                    var leftProvider = new DiagnosticsSquiggleTaggerProvider(diagnosticService, foregroundService, listenerProvider);
                    var leftTagger   = leftProvider.CreateTagger <IErrorTag>(leftBuffer);
                    using (var leftDisposable = leftTagger as IDisposable)
                    {
                        var rightBuffer   = diffView.Viewer.RightView.BufferGraph.GetTextBuffers(t => t.ContentType.IsOfType(ContentTypeNames.CSharpContentType)).First();
                        var rightProvider = new DiagnosticsSquiggleTaggerProvider(diagnosticService, foregroundService, listenerProvider);
                        var rightTagger   = rightProvider.CreateTagger <IErrorTag>(rightBuffer);
                        using (var rightDisposable = rightTagger as IDisposable)
                        {
                            // wait for diagnostics and taggers
                            await listenerProvider.WaitAllDispatcherOperationAndTasksAsync(FeatureAttribute.DiagnosticService, FeatureAttribute.ErrorSquiggles);

                            // check left buffer
                            var leftSnapshot = leftBuffer.CurrentSnapshot;
                            var leftSpans    = leftTagger.GetTags(leftSnapshot.GetSnapshotSpanCollection()).ToList();
                            Assert.Equal(1, leftSpans.Count);

                            // check right buffer
                            var rightSnapshot = rightBuffer.CurrentSnapshot;
                            var rightSpans    = rightTagger.GetTags(rightSnapshot.GetSnapshotSpanCollection()).ToList();
                            Assert.Equal(0, rightSpans.Count);
                        }
                    }
                }
            }
        }