提交 68dfab7b 编写于 作者: G Gen Lu

Fix import completion crash in interactive window

上级 80f2edbc
......@@ -152,8 +152,13 @@ async Task<ImmutableArray<CompletionItem>> HandleReferenceAsync(IAssemblySymbol
// Skip reference with only non-global alias.
var metadataReference = compilation.GetMetadataReference(referencedAssemblySymbol);
if (metadataReference.Properties.Aliases.IsEmpty ||
metadataReference.Properties.Aliases.Any(alias => alias == MetadataReferenceProperties.GlobalAlias))
// metadataReference can be null for script compilation, because compilations of previous
// submissions are treated as referenced assemblies. We don't need to check for unimported
// type from those previous submissions since namespace declarations is not allowed in script.
if (metadataReference != null &&
(metadataReference.Properties.Aliases.IsEmpty ||
metadataReference.Properties.Aliases.Any(alias => alias == MetadataReferenceProperties.GlobalAlias)))
{
var assemblyProject = project.Solution.GetProject(referencedAssemblySymbol, cancellationToken);
if (assemblyProject != null && assemblyProject.SupportsCompilation)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册