✅ CompletionService.GetService on document returns NULL in Net7 worked fine in Net6 Solved,

Fixed, by adding Microsoft.CodeAnalysis.Features Microsoft.CodeAnalysis.CSharp.Features versions. Hi, I have a problem with mentioned method, var workspace = new AdhocWorkspace(); var compilationOptions = new CSharpCompilationOptions( OutputKind.DynamicallyLinkedLibrary, usings: new[] { "System", "System.Linq" }); var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Create(), "SampleProject", "SampleProject", LanguageNames.CSharp) .WithMetadataReferences(Net70.References.All) .WithCompilationOptions(compilationOptions); var project = workspace.AddProject(projectInfo); // Add the Customer class as an additional document var customerClassCode = """
"""; var customerDocument = project.AddDocument("Customer.cs", SourceText.From(customerClassCode)); var customerDocumentProject = customerDocument.Project; var compilationAsync = await customerDocumentProject.GetCompilationAsync(); var immutableArray = compilationAsync.GetDiagnostics(); // Assert.DoesNotContain(immutableArray, x=>x.Severity == DiagnosticSeverity.Error); var position = customerClassCode.LastIndexOf('.') + 2; var completionService = CompletionService.GetService(customerDocument); var results = await completionService.GetCompletionsAsync(customerDocument, position); Assert.Contains(results.ItemsList, x => x.DisplayText == "Name");
4 Replies
Thinker
Thinker2y ago
Better ask in #roslyn probably
Erik SImonič
Erik SImoničOP2y ago
solved,
Thinker
Thinker2y ago
$close
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server