So I'm using Roslyn to generate intellisense results for a solution with many files, and I need to update the document every key press. Creating the sourcetext instance and the new solution takes very little time, but calling workspace.TryApplyChanges
takes around 500ms per key press, which is too much for me. Am I doing this wrong? (I just want to generate completion results from the workspace through CompletionService
. Here is how I'm updating my workspace:
SourceText sourceText = SourceText.From(editorText);
Solution newSolution = solutionDocument.Project.Solution.WithDocumentText(solutionDocument.Id, sourceText);
solutionWorkspace.TryApplyChanges(newSolution); //Every other part is pretty quick, except this.
solutionDocument = solutionWorkspace.CurrentSolution.GetDocument(solutionDocument.Id);
I am calling the above code EVERY single time the user types. Is there any way to make this quicker? Thanks.