public async Task CrefCompletionSpeculatesOutsideTrivia() { var text = @" /// <see cref=""$$ class C { }"; using (var workspace = TestWorkspace.Create(LanguageNames.CSharp, new CSharpCompilationOptions(OutputKind.ConsoleApplication), new CSharpParseOptions(), new[] { text })) { var called = false; var provider = new CrefCompletionProvider(testSpeculativeNodeCallbackOpt: n => { // asserts that we aren't be asked 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. called = true; var parent = n.GetAncestor <DocumentationCommentTriviaSyntax>(); Assert.Null(parent); }); var hostDocument = workspace.DocumentWithCursor; var document = workspace.CurrentSolution.GetDocument(hostDocument.Id); var service = CreateCompletionService(workspace, ImmutableArray.Create <CompletionProvider>(provider)); var completionList = await GetCompletionListAsync(service, document, hostDocument.CursorPosition.Value, CompletionTrigger.Invoke); Assert.True(called); } }
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; } }
public async Task CrefCompletionSpeculatesOutsideTrivia() { var text = @" /// <see cref=""$$ class C { }"; var exportProvider = MinimalTestExportProvider.CreateExportProvider(TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithPart(typeof(PickySemanticFactsService))); using (var workspace = await TestWorkspace.CreateAsync(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 service = GetCompletionService(workspace); var completionList = await GetCompletionListAsync(service, document, hostDocument.CursorPosition.Value, CompletionTrigger.Default); } }
public TestAccessor(CrefCompletionProvider crefCompletionProvider) =>