Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Peek into project refs to give more details to the IDE #948

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/Microsoft.Framework.DesignTimeHost/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -887,16 +887,41 @@ private DependencyInfo ResolveProjectDepencies(Project project, string configura
if (string.Equals(library.Type, "Project") &&
!string.Equals(library.Identity.Name, project.Name))
{
info.ProjectReferences.Add(new ProjectReference
Project referencedProject;
if (!Project.TryGetProject(library.Path, out referencedProject))
{
Framework = new FrameworkData
// Should never happen
continue;
}

var targetFrameworkInformation = referencedProject.GetTargetFramework(library.Framework);

// If this is an assembly reference then treat it like a file reference
if (!string.IsNullOrEmpty(targetFrameworkInformation.AssemblyPath) &&
string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject))
{
info.References.Add(GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.AssemblyPath));
}
else
{
string projectPath = library.Path;

if (!string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject))
{
ShortName = VersionUtility.GetShortFrameworkName(library.Framework),
FrameworkName = library.Framework.ToString(),
FriendlyName = frameworkResolver.GetFriendlyFrameworkName(library.Framework)
},
Path = library.Path
});
projectPath = GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.WrappedProject);
}

info.ProjectReferences.Add(new ProjectReference
{
Framework = new FrameworkData
{
ShortName = VersionUtility.GetShortFrameworkName(library.Framework),
FrameworkName = library.Framework.ToString(),
FriendlyName = frameworkResolver.GetFriendlyFrameworkName(library.Framework)
},
Path = projectPath
});
}
}
}

Expand Down Expand Up @@ -931,6 +956,11 @@ private DependencyInfo ResolveProjectDepencies(Project project, string configura
});
}

private static string GetProjectRelativeFullPath(Project referencedProject, string path)
{
return Path.GetFullPath(Path.Combine(referencedProject.ProjectDirectory, path));
}

private static DependencyDescription CreateDependencyDescription(LibraryDescription library)
{
return new DependencyDescription
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Framework.Runtime/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ private bool BuildTargetFrameworkNode(KeyValuePair<string, JToken> targetFramewo

targetFrameworkInformation.Dependencies.AddRange(frameworkAssemblies);

targetFrameworkInformation.WrappedProject = GetValue<string>(properties, "wrappedProject");

var binNode = properties["bin"];

if (binNode != null)
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Framework.Runtime/TargetFrameworkInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class TargetFrameworkInformation : IFrameworkTargetable

public IList<LibraryDependency> Dependencies { get; set; }

public string WrappedProject { get; set; }

public string AssemblyPath { get; set; }

public string PdbPath { get; set; }
Expand Down