-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Remove the PreviewWorkspace SolutionCrawler functionality #67027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,14 @@ | |
| using Microsoft.CodeAnalysis.Shared.Extensions; | ||
| using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
| using Microsoft.CodeAnalysis.SolutionCrawler; | ||
| using Microsoft.CodeAnalysis.Storage; | ||
| using Microsoft.CodeAnalysis.Test.Utilities; | ||
| using Microsoft.CodeAnalysis.Text; | ||
| using Microsoft.CodeAnalysis.Text.Shared.Extensions; | ||
| using Microsoft.VisualStudio.Text.Tagging; | ||
| using Roslyn.Test.Utilities; | ||
| using Roslyn.Utilities; | ||
| using Xunit; | ||
| using Microsoft.CodeAnalysis.Storage; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.Editor.UnitTests.Preview | ||
| { | ||
|
|
@@ -125,52 +125,15 @@ public async Task TestPreviewServices() | |
| { | ||
| using var previewWorkspace = new PreviewWorkspace(EditorTestCompositions.EditorFeatures.GetHostServices()); | ||
| var service = previewWorkspace.Services.GetService<ISolutionCrawlerRegistrationService>(); | ||
| Assert.IsType<PreviewSolutionCrawlerRegistrationServiceFactory.Service>(service); | ||
| var registrationService = Assert.IsType<SolutionCrawlerRegistrationService>(service); | ||
| Assert.False(registrationService.Register(previewWorkspace)); | ||
|
|
||
| var persistentService = previewWorkspace.Services.SolutionServices.GetPersistentStorageService(); | ||
|
|
||
| await using var storage = await persistentService.GetStorageAsync(SolutionKey.ToSolutionKey(previewWorkspace.CurrentSolution), CancellationToken.None); | ||
| Assert.IsType<NoOpPersistentStorage>(storage); | ||
| } | ||
|
|
||
| [WorkItem(923196, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/923196")] | ||
| [WpfFact] | ||
| public async Task TestPreviewDiagnostic() | ||
| { | ||
| var hostServices = EditorTestCompositions.EditorFeatures.GetHostServices(); | ||
| var exportProvider = (IMefHostExportProvider)hostServices; | ||
|
|
||
| var diagnosticService = (IDiagnosticUpdateSource)exportProvider.GetExportedValue<IDiagnosticAnalyzerService>(); | ||
| RoslynDebug.AssertNotNull(diagnosticService); | ||
| var globalOptions = exportProvider.GetExportedValue<IGlobalOptionService>(); | ||
|
|
||
| var taskSource = new TaskCompletionSource<DiagnosticsUpdatedArgs>(); | ||
| diagnosticService.DiagnosticsUpdated += (s, a) => taskSource.TrySetResult(a); | ||
|
|
||
| using var previewWorkspace = new PreviewWorkspace(hostServices); | ||
|
|
||
| var solution = previewWorkspace.CurrentSolution | ||
| .WithAnalyzerReferences(new[] { DiagnosticExtensions.GetCompilerDiagnosticAnalyzerReference(LanguageNames.CSharp) }) | ||
| .AddProject("project", "project.dll", LanguageNames.CSharp) | ||
| .AddDocument("document", "class { }") | ||
| .Project | ||
| .Solution; | ||
|
|
||
| Assert.True(previewWorkspace.TryApplyChanges(solution)); | ||
|
|
||
| var document = previewWorkspace.CurrentSolution.Projects.First().Documents.Single(); | ||
|
|
||
| previewWorkspace.OpenDocument(document.Id, (await document.GetTextAsync()).Container); | ||
| previewWorkspace.EnableSolutionCrawler(); | ||
|
|
||
| // wait 20 seconds | ||
| taskSource.Task.Wait(20000); | ||
| Assert.True(taskSource.Task.IsCompleted); | ||
|
|
||
| var args = taskSource.Task.Result; | ||
| Assert.True(args.Diagnostics.Length > 0); | ||
| } | ||
|
|
||
| [WpfFact] | ||
| public async Task TestPreviewDiagnosticTagger() | ||
| { | ||
|
|
@@ -201,9 +164,6 @@ public async Task TestPreviewDiagnosticTaggerInPreviewPane() | |
|
|
||
| workspace.TryApplyChanges(workspace.CurrentSolution.WithAnalyzerReferences(new[] { DiagnosticExtensions.GetCompilerDiagnosticAnalyzerReference(LanguageNames.CSharp) })); | ||
|
|
||
| // set up listener to wait until diagnostic finish running | ||
| _ = workspace.ExportProvider.GetExportedValue<IDiagnosticService>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was previously using push. updated to pull below. |
||
|
|
||
| var hostDocument = workspace.Projects.First().Documents.First(); | ||
|
|
||
| // make a change to remove squiggle | ||
|
|
@@ -221,18 +181,30 @@ public async Task TestPreviewDiagnosticTaggerInPreviewPane() | |
|
|
||
| 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 provider = workspace.ExportProvider.GetExportedValues<ITaggerProvider>().OfType<DiagnosticsSquiggleTaggerProvider>().Single(); | ||
| var leftTagger = provider.CreateTagger<IErrorTag>(leftBuffer); | ||
| Contract.ThrowIfNull(leftTagger); | ||
|
|
||
| using var leftDisposable = leftTagger as IDisposable; | ||
| // set up tagger for both buffers | ||
| var leftBuffer = diffView.Viewer.LeftView.BufferGraph.GetTextBuffers(t => t.ContentType.IsOfType(ContentTypeNames.CSharpContentType)).First(); | ||
| var rightBuffer = diffView.Viewer.RightView.BufferGraph.GetTextBuffers(t => t.ContentType.IsOfType(ContentTypeNames.CSharpContentType)).First(); | ||
|
|
||
| var leftDocument = leftBuffer.GetRelatedDocuments().Single(); | ||
| var rightDocument = rightBuffer.GetRelatedDocuments().Single(); | ||
|
|
||
| // Diagnostic analyzer service, which provides pull capabilities (and not to be confused with | ||
| // IDiagnosticService, which is push), doesn't normally register for test workspace. So do it explicitly. | ||
| var diagnosticAnalyzer = workspace.ExportProvider.GetExportedValue<IDiagnosticAnalyzerService>(); | ||
| var incrementalAnalyzer = (IIncrementalAnalyzerProvider)diagnosticAnalyzer; | ||
| incrementalAnalyzer.CreateIncrementalAnalyzer(leftDocument.Project.Solution.Workspace); | ||
| incrementalAnalyzer.CreateIncrementalAnalyzer(rightDocument.Project.Solution.Workspace); | ||
|
|
||
| var leftTagger = provider.CreateTagger<IErrorTag>(leftBuffer); | ||
| var rightTagger = provider.CreateTagger<IErrorTag>(rightBuffer); | ||
| Contract.ThrowIfNull(leftTagger); | ||
| Contract.ThrowIfNull(rightTagger); | ||
|
|
||
| using var leftDisposable = leftTagger as IDisposable; | ||
| using var rightDisposable = rightTagger as IDisposable; | ||
|
|
||
| // wait for diagnostics and taggers | ||
| await listenerProvider.WaitAllDispatcherOperationAndTasksAsync(workspace, FeatureAttribute.DiagnosticService, FeatureAttribute.ErrorSquiggles); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,9 @@ | |
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.Diagnostics.EngineV2; | ||
| using Microsoft.CodeAnalysis.Host.Mef; | ||
| using Microsoft.CodeAnalysis.Internal.Log; | ||
| using Microsoft.CodeAnalysis.Options; | ||
| using Microsoft.CodeAnalysis.SolutionCrawler; | ||
| using Roslyn.Utilities; | ||
|
|
||
|
|
@@ -21,17 +18,12 @@ internal partial class DiagnosticAnalyzerService : IIncrementalAnalyzerProvider | |
| { | ||
| public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) | ||
| { | ||
| if (GlobalOptions.IsLspPullDiagnostics()) | ||
| { | ||
| // We rely on LSP to query us for diagnostics when things have changed and poll us for changes that might | ||
| // have happened to the project or closed files outside of VS. | ||
| // However, we still need to create the analyzer so that the map contains the analyzer to run when pull diagnostics asks. | ||
| _ = _map.GetValue(workspace, _createIncrementalAnalyzer); | ||
|
|
||
| return NoOpIncrementalAnalyzer.Instance; | ||
| } | ||
| var analyzer = _map.GetValue(workspace, _createIncrementalAnalyzer); | ||
|
|
||
| return _map.GetValue(workspace, _createIncrementalAnalyzer); | ||
| // We rely on LSP to query us for diagnostics when things have changed and poll us for changes that might | ||
| // have happened to the project or closed files outside of VS. However, we still need to create the analyzer | ||
| // so that the map contains the analyzer to run when pull diagnostics asks. | ||
| return GlobalOptions.IsLspPullDiagnostics() ? NoOpIncrementalAnalyzer.Instance : analyzer; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same logic a before. i just rejiggered. in both paths below we were adding hte item to the map. i pulled that above, and then just changed the logic if the NoOp analyzer is returned or the actual instance. |
||
| } | ||
|
|
||
| public void ShutdownAnalyzerFrom(Workspace workspace) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull tagger test is below. this one was testing the push/solution-crawler version.