提交 ecdcde5b 编写于 作者: P Pent Ploompuu

Keep compilation alive in GetPartialSemanticModelAsync

上级 77be4787
......@@ -181,7 +181,11 @@ public static async Task<SemanticModel> GetPartialSemanticModelAsync(this Docume
if (document.Project.TryGetCompilation(out var compilation))
{
// We already have a compilation, so at this point it's fastest to just get a SemanticModel
return await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
// Make sure the compilation is kept alive so that GetSemanticModelAsync() doesn't become expensive
GC.KeepAlive(compilation);
return semanticModel;
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册