提交 a7e4c1ec 编写于 作者: B BalajiKris

Ignore assembly names when resolving symbols in Peek.

This is because peek uses symbolkeys to resolve symbols between compilations which could potentially be from different frameworks but symbolkeys do not contain enough information to deal with typeforwarding situations. E.g: a portable project and a non-portable project may both resolve the same Int32 symbol to System.Runtime and mscorlib.

Other features such as Metadata as source, Find References already do this. This change updates Peek to do the same thing. (changeset 1407182)
上级 491deef8
......@@ -60,7 +60,7 @@ public void FindResults(string relationshipName, IPeekResultCollection resultCol
var project = solution.GetProject(_peekableItem._projectId);
var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var symbol = _peekableItem._symbolKey.Resolve(compilation, cancellationToken: cancellationToken).Symbol;
var symbol = _peekableItem._symbolKey.Resolve(compilation, ignoreAssemblyKey:true, cancellationToken: cancellationToken).Symbol;
if (symbol == null)
{
callback.ReportFailure(new Exception(EditorFeaturesResources.NoInformationFound));
......
......@@ -140,6 +140,47 @@ End Module
End Using
End Sub
<Fact>
<WorkItem(1091211)>
Public Sub PeekAcrossProjectsInvolvingPortableReferences()
Dim workspaceDefinition =
<Workspace>
<Project Language="C#" AssemblyName="CSharpAssembly" CommonReferencesPortable="true">
<Document>
namespace N
{
public class CSClass
{
public void {|Identifier:M|}(int i) { }
}
}
</Document>
</Project>
<Project Language="Visual Basic" AssemblyName="VBAssembly" CommonReferences="true" CommonReferenceFacadeSystemRuntime="true">
<ProjectReference>CSharpAssembly</ProjectReference>
<Document>
Imports N
Public Class VBClass
Sub Test()
Dim x As New CSClass()
x.M$$(5)
End Sub
End Class
</Document>
</Project>
</Workspace>
Using workspace = TestWorkspaceFactory.CreateWorkspace(workspaceDefinition)
Dim result = GetPeekResultCollection(workspace)
Assert.Equal(1, result.Items.Count)
result.AssertNavigatesToIdentifier(0, "Identifier")
End Using
End Sub
Private Function GetPeekResultCollection(workspace As XElement) As PeekResultCollection
Using testWorkspace = TestWorkspaceFactory.CreateWorkspace(workspace)
Return GetPeekResultCollection(testWorkspace)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册