private void Test(string fileContents, params OutliningSpan[] expectedSpans) { var workspace = TestWorkspaceFactory.CreateWorkspaceFromFiles(WorkspaceKind.MetadataAsSource, LanguageNames.CSharp, null, null, fileContents); var outliningService = workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetService <IOutliningService>(); var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); var actualOutliningSpans = outliningService.GetOutliningSpansAsync(document, CancellationToken.None).Result.Where(s => s != null).ToArray(); Assert.Equal(expectedSpans.Length, actualOutliningSpans.Length); for (int i = 0; i < expectedSpans.Length; i++) { AssertRegion(expectedSpans[i], actualOutliningSpans[i]); } }
public void CrefCompletionSpeculatesOutsideTrivia() { var text = @" /// <see cref=""$$ class C { }"; var exportProvider = MinimalTestExportProvider.CreateExportProvider(TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithPart(typeof(PickySemanticFactsService))); using (var workspace = TestWorkspaceFactory.CreateWorkspaceFromFiles(LanguageNames.CSharp, new CSharpCompilationOptions(OutputKind.ConsoleApplication), new CSharpParseOptions(), new[] { text }, exportProvider)) { // This test uses MEF to compose in an ISyntaxFactsService that // asserts it isn't asked to speculate on nodes inside documentation trivia. // This verifies that the provider is asking for a speculative SemanticModel // by walking to the node the documentation is attached to. var provider = new CrefCompletionProvider(); var hostDocument = workspace.DocumentWithCursor; var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var items = provider.GetGroupAsync(document, hostDocument.CursorPosition.Value, CompletionTriggerInfo.CreateInvokeCompletionTriggerInfo(), CancellationToken.None).Result; } }