From adaf7f9be48663c2b22ab34c0092b98e479b1df5 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 16 Oct 2015 22:50:44 -0700 Subject: [PATCH] Fixed compilation issues with source exports - Dependencies can have multiple parents. Fix the object model for that. - Also moved shared file resolution to the right spot --- .../Compilation/LibraryExporter.cs | 15 +++++++-------- .../LibraryDescription.cs | 2 +- .../ProjectContextBuilder.cs | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.Extensions.ProjectModel/Compilation/LibraryExporter.cs b/src/Microsoft.Extensions.ProjectModel/Compilation/LibraryExporter.cs index 096f31276..b9fa9f492 100644 --- a/src/Microsoft.Extensions.ProjectModel/Compilation/LibraryExporter.cs +++ b/src/Microsoft.Extensions.ProjectModel/Compilation/LibraryExporter.cs @@ -51,12 +51,11 @@ namespace Microsoft.Extensions.ProjectModel.Compilation private IEnumerable ExportLibraries(Func condition) { var seenMetadataReferences = new HashSet(); - var seenRuntimeReferences = new HashSet(); // Iterate over libraries in the library manager foreach (var library in LibraryManager.GetLibraries()) { - if(!condition(library)) + if (!condition(library)) { continue; } @@ -78,7 +77,7 @@ namespace Microsoft.Extensions.ProjectModel.Compilation } } - if (library.Parent != null && Equals(library.Parent.Identity, _rootProject.Identity)) + if (library.Parents.Contains(_rootProject)) { // Only process source references for direct dependencies foreach (var sourceReference in libraryExport.SourceReferences) @@ -153,12 +152,12 @@ namespace Microsoft.Extensions.ProjectModel.Compilation { compileAssemblies.Add(outputPath); } + } - // Add shared sources - foreach (var sharedFile in project.Project.Files.SharedFiles) - { - sourceReferences.Add(sharedFile); - } + // Add shared sources + foreach (var sharedFile in project.Project.Files.SharedFiles) + { + sourceReferences.Add(sharedFile); } // No support for ref or native in projects, so runtimeAssemblies is just the same as compileAssemblies and nativeLibraries are empty diff --git a/src/Microsoft.Extensions.ProjectModel/LibraryDescription.cs b/src/Microsoft.Extensions.ProjectModel/LibraryDescription.cs index e380ba31a..2796dd532 100644 --- a/src/Microsoft.Extensions.ProjectModel/LibraryDescription.cs +++ b/src/Microsoft.Extensions.ProjectModel/LibraryDescription.cs @@ -33,7 +33,7 @@ namespace Microsoft.Extensions.ProjectModel public LibraryRange RequestedRange { get; } public LibraryIdentity Identity { get; } - public LibraryDescription Parent { get; set; } + public List Parents { get; set; } = new List(); public string Path { get; } public IEnumerable Dependencies { get; } public bool Compatible { get; } diff --git a/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs b/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs index 2f396f842..49f4e8d59 100644 --- a/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs +++ b/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs @@ -157,7 +157,7 @@ namespace Microsoft.Extensions.ProjectModel } } - dep.Parent = library; + dep.Parents.Add(library); } } }