未验证 提交 1cf4bb41 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #28483 from MaStr11/fix_InternalsVisibleToCompletionProvider_XamlProjects

Fix InternalsVisibleToCompletionProvider showing unsupported project types
......@@ -580,5 +580,23 @@ using System.Reflection;
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary2"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIgnoresUnsupportedProjectTypes() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="NoCompilation" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly: InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertNoCompletionSession()
End Using
End Function
End Class
End Namespace
......@@ -62,8 +62,10 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
If extraCompletionProviders IsNot Nothing Then
Dim completionService = DirectCast(languageServices.GetService(Of CompletionService), CompletionServiceWithProviders)
If completionService IsNot Nothing Then
completionService.SetTestProviders(extraCompletionProviders.Select(Function(lz) lz.Value).ToList())
End If
End If
Me.SessionTestState = GetExportedValue(Of IIntelliSenseTestState)()
......
......@@ -130,6 +130,11 @@ private async Task AddAssemblyCompletionItemsAsync(CompletionContext context, Ca
continue;
}
if (IsProjectTypeUnsupported(project))
{
continue;
}
if (allInternalsVisibleToAttributesOfProject.Contains(project.AssemblyName))
{
continue;
......@@ -145,6 +150,9 @@ private async Task AddAssemblyCompletionItemsAsync(CompletionContext context, Ca
}
}
private static bool IsProjectTypeUnsupported(Project project)
=> !project.SupportsCompilation;
private async Task<IImmutableSet<string>> GetAllInternalsVisibleToAssemblyNamesOfProjectAsync(CompletionContext completionContext, CancellationToken cancellationToken)
{
// Looking up other InternalsVisibleTo attributes of this project. This is faster than compiling all projects of the solution and checking access via
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册