Add runtime signature into deps.json

This commit is contained in:
Pavel Krymets 2016-03-23 14:51:03 -07:00
parent a81f1c08f0
commit f75481f731
15 changed files with 187 additions and 78 deletions

View file

@ -83,6 +83,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "update-dependencies", "scri
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Cli.Utils.Tests", "test\Microsoft.DotNet.Cli.Utils.Tests\Microsoft.DotNet.Cli.Utils.Tests.xproj", "{09C52F96-EFDD-4448-95EC-6D362DD60BAA}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Cli.Utils.Tests", "test\Microsoft.DotNet.Cli.Utils.Tests\Microsoft.DotNet.Cli.Utils.Tests.xproj", "{09C52F96-EFDD-4448-95EC-6D362DD60BAA}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RuntimeGraphGenerator", "tools\RuntimeGraphGenerator\RuntimeGraphGenerator.xproj", "{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -591,6 +593,22 @@ Global
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.Build.0 = Release|Any CPU {09C52F96-EFDD-4448-95EC-6D362DD60BAA}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Debug|x64.Build.0 = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|Any CPU.Build.0 = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|x64.ActiveCfg = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.Release|x64.Build.0 = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -629,5 +647,6 @@ Global
{60C33D0A-A5D8-4AB0-9956-1F804654DF05} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7} {60C33D0A-A5D8-4AB0-9956-1F804654DF05} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3} {A28BD8AC-DF15-4F58-8299-98A9AE2B8726} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{09C52F96-EFDD-4448-95EC-6D362DD60BAA} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7} {09C52F96-EFDD-4448-95EC-6D362DD60BAA} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{EFC4FE68-83EB-40E4-BFA8-61D0B4626F25} = {0722D325-24C8-4E83-B5AF-0A083E7F0749}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -1,3 +1,3 @@
{ {
"projects": [ "src", "test" ] "projects": [ "src", "test", "tools" ]
} }

View file

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Compilation; using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.DotNet.ProjectModel.Graph; using Microsoft.DotNet.ProjectModel.Graph;
@ -49,16 +51,41 @@ namespace Microsoft.Extensions.DependencyModel
var compilationOptions = compilerOptions != null var compilationOptions = compilerOptions != null
? GetCompilationOptions(compilerOptions) ? GetCompilationOptions(compilerOptions)
: CompilationOptions.Default; : CompilationOptions.Default;
var runtimeSignature = GenerateRuntimeSignature(runtimeExports);
return new DependencyContext( return new DependencyContext(
target.DotNetFrameworkName, new TargetInfo(target.DotNetFrameworkName, runtime, runtimeSignature, portable),
runtime,
portable,
compilationOptions, compilationOptions,
GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(), GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(),
GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(), GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(),
new RuntimeFallbacks[] {}); new RuntimeFallbacks[] {});
} }
private static string GenerateRuntimeSignature(IEnumerable<LibraryExport> runtimeExports)
{
var sha1 = SHA1.Create();
var builder = new StringBuilder();
var packages = runtimeExports
.Where(libraryExport => libraryExport.Library.Identity.Type == LibraryType.Package);
var seperator = "|";
foreach (var libraryExport in packages)
{
builder.Append(libraryExport.Library.Identity.Name);
builder.Append(seperator);
builder.Append(libraryExport.Library.Identity.Version.ToString());
builder.Append(seperator);
}
var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString()));
builder.Clear();
foreach (var b in hash)
{
builder.AppendFormat("{0:x2}", b);
}
return builder.ToString();
}
private static CompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions) private static CompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions)
{ {
return new CompilationOptions(compilerOptions.Defines, return new CompilationOptions(compilerOptions.Defines,

View file

@ -10,21 +10,47 @@ using Microsoft.Extensions.PlatformAbstractions;
namespace Microsoft.Extensions.DependencyModel namespace Microsoft.Extensions.DependencyModel
{ {
public class TargetInfo
{
public TargetInfo(string framework,
string runtime,
string runtimeSignature,
bool isPortable)
{
if (string.IsNullOrEmpty(framework))
{
throw new ArgumentException(nameof(framework));
}
Framework = framework;
Runtime = runtime;
RuntimeSignature = runtimeSignature;
IsPortable = isPortable;
}
public string Framework { get; }
public string Runtime { get; }
public string RuntimeSignature { get; }
public bool IsPortable { get; }
}
public class DependencyContext public class DependencyContext
{ {
private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault); private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault);
public DependencyContext(string targetFramework, public DependencyContext(TargetInfo target,
string runtime,
bool isPortable,
CompilationOptions compilationOptions, CompilationOptions compilationOptions,
IEnumerable<CompilationLibrary> compileLibraries, IEnumerable<CompilationLibrary> compileLibraries,
IEnumerable<RuntimeLibrary> runtimeLibraries, IEnumerable<RuntimeLibrary> runtimeLibraries,
IEnumerable<RuntimeFallbacks> runtimeGraph) IEnumerable<RuntimeFallbacks> runtimeGraph)
{ {
if (string.IsNullOrEmpty(targetFramework)) if (target == null)
{ {
throw new ArgumentException(nameof(targetFramework)); throw new ArgumentNullException(nameof(target));
} }
if (compilationOptions == null) if (compilationOptions == null)
{ {
@ -43,9 +69,7 @@ namespace Microsoft.Extensions.DependencyModel
throw new ArgumentNullException(nameof(runtimeGraph)); throw new ArgumentNullException(nameof(runtimeGraph));
} }
TargetFramework = targetFramework; Target = target;
Runtime = runtime;
IsPortable = isPortable;
CompilationOptions = compilationOptions; CompilationOptions = compilationOptions;
CompileLibraries = compileLibraries.ToArray(); CompileLibraries = compileLibraries.ToArray();
RuntimeLibraries = runtimeLibraries.ToArray(); RuntimeLibraries = runtimeLibraries.ToArray();
@ -54,11 +78,7 @@ namespace Microsoft.Extensions.DependencyModel
public static DependencyContext Default => _defaultContext.Value; public static DependencyContext Default => _defaultContext.Value;
public string TargetFramework { get; } public TargetInfo Target { get; }
public string Runtime { get; }
public bool IsPortable { get; }
public CompilationOptions CompilationOptions { get; } public CompilationOptions CompilationOptions { get; }
@ -76,9 +96,7 @@ namespace Microsoft.Extensions.DependencyModel
} }
return new DependencyContext( return new DependencyContext(
TargetFramework, Target,
Runtime,
IsPortable,
CompilationOptions, CompilationOptions,
CompileLibraries.Union(other.CompileLibraries, new LibraryMergeEqualityComparer<CompilationLibrary>()), CompileLibraries.Union(other.CompileLibraries, new LibraryMergeEqualityComparer<CompilationLibrary>()),
RuntimeLibraries.Union(other.RuntimeLibraries, new LibraryMergeEqualityComparer<RuntimeLibrary>()), RuntimeLibraries.Union(other.RuntimeLibraries, new LibraryMergeEqualityComparer<RuntimeLibrary>()),

View file

@ -35,8 +35,22 @@ namespace Microsoft.Extensions.DependencyModel
var runtime = string.Empty; var runtime = string.Empty;
var target = string.Empty; var target = string.Empty;
var isPortable = true; var isPortable = true;
string runtimeTargetName = null;
string runtimeSignature = null;
var runtimeTargetName = root[DependencyContextStrings.RuntimeTargetPropertyName]?.Value<string>(); var runtimeTargetInfo = root[DependencyContextStrings.RuntimeTargetPropertyName];
// This fallback is temporary
if (runtimeTargetInfo is JValue)
{
runtimeTargetName = runtimeTargetInfo.Value<string>();
}
else
{
var runtimeTargetObject = (JObject) runtimeTargetInfo;
runtimeTargetName = runtimeTargetObject?[DependencyContextStrings.RuntimeTargetNamePropertyName]?.Value<string>();
runtimeSignature = runtimeTargetObject?[DependencyContextStrings.RuntimeTargetSignaturePropertyName]?.Value<string>();
}
var libraryStubs = ReadLibraryStubs((JObject)root[DependencyContextStrings.LibrariesPropertyName]); var libraryStubs = ReadLibraryStubs((JObject)root[DependencyContextStrings.LibrariesPropertyName]);
var targetsObject = (JObject)root[DependencyContextStrings.TargetsPropertyName]; var targetsObject = (JObject)root[DependencyContextStrings.TargetsPropertyName];
@ -98,9 +112,7 @@ namespace Microsoft.Extensions.DependencyModel
} }
return new DependencyContext( return new DependencyContext(
target, new TargetInfo(target, runtime, runtimeSignature, isPortable),
runtime,
isPortable,
ReadCompilationOptions((JObject)root[DependencyContextStrings.CompilationOptionsPropertName]), ReadCompilationOptions((JObject)root[DependencyContextStrings.CompilationOptionsPropertName]),
ReadLibraries(compileTarget, false, libraryStubs).Cast<CompilationLibrary>().ToArray(), ReadLibraries(compileTarget, false, libraryStubs).Cast<CompilationLibrary>().ToArray(),
ReadLibraries(runtimeTarget, true, libraryStubs).Cast<RuntimeLibrary>().ToArray(), ReadLibraries(runtimeTarget, true, libraryStubs).Cast<RuntimeLibrary>().ToArray(),

View file

@ -71,7 +71,7 @@ namespace Microsoft.Extensions.DependencyModel
context = LoadAssemblyContext(assembly); context = LoadAssemblyContext(assembly);
} }
if (context?.IsPortable == true) if (context?.Target.IsPortable == true)
{ {
var runtimeContext = LoadRuntimeContext(); var runtimeContext = LoadRuntimeContext();
if (runtimeContext != null) if (runtimeContext != null)

View file

@ -57,6 +57,8 @@ namespace Microsoft.Extensions.DependencyModel
internal const string RuntimeTargetNamePropertyName = "name"; internal const string RuntimeTargetNamePropertyName = "name";
internal const string RuntimeTargetSignaturePropertyName = "signature";
internal const string RuntimesPropertyName = "runtimes"; internal const string RuntimesPropertyName = "runtimes";
internal const string RuntimeTargetsPropertyName = "runtimeTargets"; internal const string RuntimeTargetsPropertyName = "runtimeTargets";

View file

@ -48,11 +48,18 @@ namespace Microsoft.Extensions.DependencyModel
return contextObject; return contextObject;
} }
private string WriteRuntimeTargetInfo(DependencyContext context) private JObject WriteRuntimeTargetInfo(DependencyContext context)
{ {
return context.IsPortable ? return new JObject(
context.TargetFramework : new JProperty(DependencyContextStrings.RuntimeTargetNamePropertyName,
context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime; context.Target.IsPortable ?
context.Target.Framework :
context.Target.Framework + DependencyContextStrings.VersionSeperator + context.Target.Runtime
),
new JProperty(DependencyContextStrings.RuntimeTargetSignaturePropertyName,
context.Target.RuntimeSignature
)
);
} }
private JObject WriteRuntimeGraph(DependencyContext context) private JObject WriteRuntimeGraph(DependencyContext context)
@ -93,16 +100,16 @@ namespace Microsoft.Extensions.DependencyModel
private JObject WriteTargets(DependencyContext context) private JObject WriteTargets(DependencyContext context)
{ {
if (context.IsPortable) if (context.Target.IsPortable)
{ {
return new JObject( return new JObject(
new JProperty(context.TargetFramework, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries)) new JProperty(context.Target.Framework, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries))
); );
} }
return new JObject( return new JObject(
new JProperty(context.TargetFramework, WriteTarget(context.CompileLibraries)), new JProperty(context.Target.Framework, WriteTarget(context.CompileLibraries)),
new JProperty(context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime, new JProperty(context.Target.Framework + DependencyContextStrings.VersionSeperator + context.Target.Runtime,
WriteTarget(context.RuntimeLibraries)) WriteTarget(context.RuntimeLibraries))
); );
} }

View file

@ -319,7 +319,10 @@ bool deps_json_t::load(bool portable, const pal::string_t& deps_path, const rid_
const auto json = json_value::parse(file); const auto json = json_value::parse(file);
const auto& runtime_target = json.at(_X("runtimeTarget")); const auto& runtime_target = json.at(_X("runtimeTarget"));
const pal::string_t& name = runtime_target.as_string();
const pal::string_t& name = runtime_target.is_string()?
runtime_target.as_string():
runtime_target.at(_X("name")).as_string();
return (portable) ? load_portable(json, name, rid_fallback_graph) : load_standalone(json, name); return (portable) ? load_portable(json, name, rid_fallback_graph) : load_standalone(json, name);
} }

View file

@ -84,15 +84,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
{ {
var context = Build(portable: true); var context = Build(portable: true);
context.IsPortable.Should().BeTrue(); context.Target.IsPortable.Should().BeTrue();
} }
[Fact] [Fact]
public void FillsRuntimeAndTarget() public void FillsRuntimeAndTarget()
{ {
var context = Build(target: new NuGetFramework("SomeFramework",new Version(1,2)), runtime: "win8-x86"); var context = Build(target: new NuGetFramework("SomeFramework",new Version(1,2)), runtime: "win8-x86");
context.Runtime.Should().Be("win8-x86"); context.Target.Runtime.Should().Be("win8-x86");
context.TargetFramework.Should().Be("SomeFramework,Version=v1.2"); context.Target.Framework.Should().Be("SomeFramework,Version=v1.2");
} }
[Fact] [Fact]
@ -291,6 +291,19 @@ namespace Microsoft.Extensions.DependencyModel.Tests
lib.Dependencies.Should().BeEmpty(); lib.Dependencies.Should().BeEmpty();
} }
[Fact]
public void GeneratesRuntimeSignatureOutOfPackageNamesAndVersions()
{
var context = Build(runtimeExports: new[]
{
Export(PackageDescription("Pack.Age", new NuGetVersion(1, 2, 3))),
Export(PackageDescription("Pack.Age", new NuGetVersion(1, 2, 3))),
});
context.Target.RuntimeSignature.Should().Be("d0fc00006ed69e4aae80383dda08599a6892fd31");
}
private LibraryExport Export( private LibraryExport Export(
LibraryDescription description, LibraryDescription description,
IEnumerable<LibraryAsset> compilationAssemblies = null, IEnumerable<LibraryAsset> compilationAssemblies = null,

View file

@ -25,14 +25,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests
{ {
var context = Read( var context = Read(
@"{ @"{
""runtimeTarget"": "".NETStandardApp,Version=v1.5/osx.10.10-x64"", ""runtimeTarget"": {
""name"":"".NETStandardApp,Version=v1.5/osx.10.10-x64""
},
""targets"": { ""targets"": {
"".NETStandardApp,Version=v1.5/osx.10.10-x64"": {}, "".NETStandardApp,Version=v1.5/osx.10.10-x64"": {},
} }
}"); }");
context.IsPortable.Should().BeFalse(); context.Target.IsPortable.Should().BeFalse();
context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5"); context.Target.Framework.Should().Be(".NETStandardApp,Version=v1.5");
context.Runtime.Should().Be("osx.10.10-x64"); context.Target.Runtime.Should().Be("osx.10.10-x64");
} }
[Fact] [Fact]
@ -44,7 +46,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
"".NETStandardApp,Version=v1.5"": {} "".NETStandardApp,Version=v1.5"": {}
} }
}"); }");
context.IsPortable.Should().BeTrue(); context.Target.IsPortable.Should().BeTrue();
} }
[Fact] [Fact]
@ -52,12 +54,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
{ {
var context = Read( var context = Read(
@"{ @"{
""runtimeTarget"": "".NETStandardApp,Version=v1.5/osx.10.10-x64"", ""runtimeTarget"": {
""name"": "".NETStandardApp,Version=v1.5/osx.10.10-x64""
},
""targets"": { ""targets"": {
"".NETStandardApp,Version=v1.5/osx.10.10-x64"": {} "".NETStandardApp,Version=v1.5/osx.10.10-x64"": {}
} }
}"); }");
context.IsPortable.Should().BeFalse(); context.Target.IsPortable.Should().BeFalse();
} }
[Fact] [Fact]
@ -69,7 +73,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
"".NETStandardApp,Version=v1.5"": {} "".NETStandardApp,Version=v1.5"": {}
} }
}"); }");
context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5"); context.Target.Framework.Should().Be(".NETStandardApp,Version=v1.5");
} }
[Fact] [Fact]
@ -152,7 +156,9 @@ namespace Microsoft.Extensions.DependencyModel.Tests
{ {
var context = Read( var context = Read(
@"{ @"{
""runtimeTarget"": "".NETStandardApp,Version=v1.5"", ""runtimeTarget"": {
""name"": "".NETStandardApp,Version=v1.5""
},
""targets"": { ""targets"": {
"".NETStandardApp,Version=v1.5"": { "".NETStandardApp,Version=v1.5"": {
""MyApp/1.0.1"": { ""MyApp/1.0.1"": {

View file

@ -37,12 +37,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
CompilationOptions compilationOptions = null, CompilationOptions compilationOptions = null,
CompilationLibrary[] compileLibraries = null, CompilationLibrary[] compileLibraries = null,
RuntimeLibrary[] runtimeLibraries = null, RuntimeLibrary[] runtimeLibraries = null,
IReadOnlyList<RuntimeFallbacks> runtimeGraph = null) IReadOnlyList<RuntimeFallbacks> runtimeGraph = null,
string runtimeSignature = null)
{ {
return new DependencyContext( return new DependencyContext(new TargetInfo(
target ?? "DefaultTarget", target ?? "DefaultTarget",
runtime ?? string.Empty, runtime ?? string.Empty,
isPortable ?? false, runtimeSignature ?? string.Empty,
isPortable ?? false),
compilationOptions ?? CompilationOptions.Default, compilationOptions ?? CompilationOptions.Default,
compileLibraries ?? new CompilationLibrary[0], compileLibraries ?? new CompilationLibrary[0],
runtimeLibraries ?? new RuntimeLibrary[0], runtimeLibraries ?? new RuntimeLibrary[0],
@ -80,10 +82,13 @@ namespace Microsoft.Extensions.DependencyModel.Tests
var result = Save(Create( var result = Save(Create(
"Target", "Target",
"runtime", "runtime",
false) false,
runtimeSignature: "runtimeSignature")
); );
result.Should().HavePropertyAsObject("runtimeTarget")
result.Should().HavePropertyValue("runtimeTarget", "Target/runtime"); .Which.Should().HavePropertyValue("name", "Target/runtime");
result.Should().HavePropertyAsObject("runtimeTarget")
.Which.Should().HavePropertyValue("signature", "runtimeSignature");
} }
[Fact] [Fact]
@ -92,9 +97,13 @@ namespace Microsoft.Extensions.DependencyModel.Tests
var result = Save(Create( var result = Save(Create(
"Target", "Target",
"runtime", "runtime",
true) true,
runtimeSignature: "runtimeSignature")
); );
result.Should().HavePropertyValue("runtimeTarget", "Target"); result.Should().HavePropertyAsObject("runtimeTarget")
.Which.Should().HavePropertyValue("name", "Target");
result.Should().HavePropertyAsObject("runtimeTarget")
.Which.Should().HavePropertyValue("signature", "runtimeSignature");
} }
[Fact] [Fact]

View file

@ -39,18 +39,14 @@ namespace Microsoft.Extensions.DependencyModel.Tests
}; };
var context = new DependencyContext( var context = new DependencyContext(
"Framework", CreateTargetInfo(),
"runtime",
true,
CompilationOptions.Default, CompilationOptions.Default,
compilationLibraries, compilationLibraries,
runtimeLibraries, runtimeLibraries,
new RuntimeFallbacks[] { }); new RuntimeFallbacks[] { });
var contextRedist = new DependencyContext( var contextRedist = new DependencyContext(
"Framework", CreateTargetInfo(),
"runtime",
true,
CompilationOptions.Default, CompilationOptions.Default,
compilationLibrariesRedist, compilationLibrariesRedist,
runtimeLibrariesRedist, runtimeLibrariesRedist,
@ -76,9 +72,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
public void MergeMergesRuntimeGraph() public void MergeMergesRuntimeGraph()
{ {
var context = new DependencyContext( var context = new DependencyContext(
"Framework", CreateTargetInfo(),
"runtime",
true,
CompilationOptions.Default, CompilationOptions.Default,
Enumerable.Empty<CompilationLibrary>(), Enumerable.Empty<CompilationLibrary>(),
Enumerable.Empty<RuntimeLibrary>(), Enumerable.Empty<RuntimeLibrary>(),
@ -88,9 +82,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
}); });
var contextRedist = new DependencyContext( var contextRedist = new DependencyContext(
"Framework", CreateTargetInfo(),
"runtime",
true,
CompilationOptions.Default, CompilationOptions.Default,
Enumerable.Empty<CompilationLibrary>(), Enumerable.Empty<CompilationLibrary>(),
Enumerable.Empty<RuntimeLibrary>(), Enumerable.Empty<RuntimeLibrary>(),
@ -106,6 +98,15 @@ namespace Microsoft.Extensions.DependencyModel.Tests
Subject.Fallbacks.Should().BeEquivalentTo("win7-x64", "win7-x86"); Subject.Fallbacks.Should().BeEquivalentTo("win7-x64", "win7-x86");
} }
private TargetInfo CreateTargetInfo()
{
return new TargetInfo(
"Framework",
"runtime",
"runtimeSignature",
true);
}
private CompilationLibrary CreateCompilation(string name) private CompilationLibrary CreateCompilation(string name)
{ {
return new CompilationLibrary( return new CompilationLibrary(

View file

@ -16,10 +16,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
[InlineData("FlibbidyFlob", "FlibbidyFlob")] [InlineData("FlibbidyFlob", "FlibbidyFlob")]
public void GetRuntimeAssemblyNamesExtractsCorrectAssemblyName(string path, string expected) public void GetRuntimeAssemblyNamesExtractsCorrectAssemblyName(string path, string expected)
{ {
var context = new DependencyContext( var context = new DependencyContext(new TargetInfo(".NETStandard,Version=v1.3", string.Empty, string.Empty, true),
".NETStandard,Version=v1.3",
string.Empty,
isPortable: true,
compilationOptions: CompilationOptions.Default, compilationOptions: CompilationOptions.Default,
compileLibraries: new CompilationLibrary[] { }, compileLibraries: new CompilationLibrary[] { },
runtimeLibraries: new[] { runtimeLibraries: new[] {
@ -94,10 +91,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
private DependencyContext BuildTestContext() private DependencyContext BuildTestContext()
{ {
return new DependencyContext( return new DependencyContext(new TargetInfo(".NETStandard,Version=v1.3", string.Empty, string.Empty, true),
".NETStandard,Version=v1.3",
string.Empty,
isPortable: true,
compilationOptions: CompilationOptions.Default, compilationOptions: CompilationOptions.Default,
compileLibraries: new[] compileLibraries: new[]
{ {

View file

@ -69,7 +69,7 @@ namespace RuntimeGraphGenerator
{ {
context = new DependencyContextJsonReader().Read(depsStream); context = new DependencyContextJsonReader().Read(depsStream);
} }
var framework = NuGetFramework.Parse(context.TargetFramework); var framework = NuGetFramework.Parse(context.Target.Framework);
var projectContext = ProjectContext.Create(projectDirectory, framework); var projectContext = ProjectContext.Create(projectDirectory, framework);
// Configuration is used only for P2P dependencies so were don't care // Configuration is used only for P2P dependencies so were don't care
@ -79,9 +79,7 @@ namespace RuntimeGraphGenerator
var expandedGraph = manager.Expand(graph, runtimes); var expandedGraph = manager.Expand(graph, runtimes);
context = new DependencyContext( context = new DependencyContext(
context.TargetFramework, context.Target,
context.Runtime,
context.IsPortable,
context.CompilationOptions, context.CompilationOptions,
context.CompileLibraries, context.CompileLibraries,
context.RuntimeLibraries, context.RuntimeLibraries,