From a7e4c1ec1422d3fcf9eccb64df6eef5bd446ca39 Mon Sep 17 00:00:00 2001 From: BalajiKris Date: Thu, 29 Jan 2015 14:51:10 -0800 Subject: [PATCH] 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) --- .../Peek/DefinitionPeekableItem.cs | 2 +- src/EditorFeatures/Test2/Peek/PeekTests.vb | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/Core/Implementation/Peek/DefinitionPeekableItem.cs b/src/EditorFeatures/Core/Implementation/Peek/DefinitionPeekableItem.cs index 9ef2f045439..6c3c17bc40b 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/DefinitionPeekableItem.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/DefinitionPeekableItem.cs @@ -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)); diff --git a/src/EditorFeatures/Test2/Peek/PeekTests.vb b/src/EditorFeatures/Test2/Peek/PeekTests.vb index d2740993b35..de7b8cec001 100644 --- a/src/EditorFeatures/Test2/Peek/PeekTests.vb +++ b/src/EditorFeatures/Test2/Peek/PeekTests.vb @@ -140,6 +140,47 @@ End Module End Using End Sub + + + + Public Sub PeekAcrossProjectsInvolvingPortableReferences() + Dim workspaceDefinition = + + + + namespace N + { + public class CSClass + { + public void {|Identifier:M|}(int i) { } + } + } + + + + CSharpAssembly + + Imports N + + Public Class VBClass + Sub Test() + Dim x As New CSClass() + x.M$$(5) + End Sub + End Class + + + + + 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) -- GitLab