public void TestGetProjectForAssemblySymbol() { var pid1 = ProjectId.CreateNewId("p1"); var pid2 = ProjectId.CreateNewId("p2"); var pid3 = ProjectId.CreateNewId("p3"); var did1 = DocumentId.CreateNewId(pid1); var did2 = DocumentId.CreateNewId(pid2); var did3 = DocumentId.CreateNewId(pid3); var text1 = @" Public Class A End Class"; var text2 = @" Public Class B End Class "; var text3 = @" public class C : B { } "; var text4 = @" public class C : A { } "; var solution = new AdhocWorkspace().CurrentSolution .AddProject(pid1, "FooA", "Foo.dll", LanguageNames.VisualBasic) .AddDocument(did1, "A.vb", text1) .AddMetadataReference(pid1, s_mscorlib) .AddProject(pid2, "FooB", "Foo2.dll", LanguageNames.VisualBasic) .AddDocument(did2, "B.vb", text2) .AddMetadataReference(pid2, s_mscorlib) .AddProject(pid3, "Bar", "Bar.dll", LanguageNames.CSharp) .AddDocument(did3, "C.cs", text3) .AddMetadataReference(pid3, s_mscorlib) .AddProjectReference(pid3, new ProjectReference(pid1)) .AddProjectReference(pid3, new ProjectReference(pid2)); var project3 = solution.GetProject(pid3); var comp3 = project3.GetCompilationAsync().Result; var classC = comp3.GetTypeByMetadataName("C"); var projectForBaseType = solution.GetProject(classC.BaseType.ContainingAssembly); Assert.Equal(pid2, projectForBaseType.Id); // switch base type to A then try again var solution2 = solution.WithDocumentText(did3, SourceText.From(text4)); project3 = solution2.GetProject(pid3); comp3 = project3.GetCompilationAsync().Result; classC = comp3.GetTypeByMetadataName("C"); projectForBaseType = solution2.GetProject(classC.BaseType.ContainingAssembly); Assert.Equal(pid1, projectForBaseType.Id); }