private static void RefactoringSetup( TestWorkspace workspace, CodeRefactoringProvider provider, List <CodeAction> codeActions, out EditorLayerExtensionManager.ExtensionManager extensionManager, out VisualStudio.Text.ITextBuffer textBuffer ) { var document = GetDocument(workspace); textBuffer = workspace.GetTestDocument(document.Id).GetTextBuffer(); var span = document.GetSyntaxRootAsync().Result.Span; var context = new CodeRefactoringContext( document, span, (a) => codeActions.Add(a), CancellationToken.None ); provider.ComputeRefactoringsAsync(context).Wait(); var action = codeActions.Single(); extensionManager = document.Project.Solution.Workspace.Services.GetService <IExtensionManager>() as EditorLayerExtensionManager.ExtensionManager; }
private static void GetDocumentAndExtensionManager( DiagnosticAnalyzerService diagnosticService, TestWorkspace workspace, out Document document, out EditorLayerExtensionManager.ExtensionManager extensionManager, MockAnalyzerReference?analyzerReference = null) { var incrementalAnalyzer = (IIncrementalAnalyzerProvider)diagnosticService; // register diagnostic engine to solution crawler _ = incrementalAnalyzer.CreateIncrementalAnalyzer(workspace); var reference = analyzerReference ?? new MockAnalyzerReference(); var project = workspace.CurrentSolution.Projects.Single().AddAnalyzerReference(reference); document = project.Documents.Single(); extensionManager = (EditorLayerExtensionManager.ExtensionManager)document.Project.Solution.Workspace.Services.GetRequiredService <IExtensionManager>(); }