From 1d7cff48d426a97f3da635e8782634df194a928e Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 4 Mar 2016 14:12:16 -0800 Subject: [PATCH] PR --- .../DependencyContextValidator/Validator.cs | 6 +- .../CompilationLibrary.cs | 6 +- .../DependencyContext.cs | 10 +- .../DependencyContextCsvReader.cs | 6 +- .../DependencyContextWriter.cs | 31 +-- .../Library.cs | 10 +- .../AppBaseCompilationAssemblyResolver.cs | 6 +- ...PackageCacheCompilationAssemblyResolver.cs | 6 +- .../PackageCompilationAssemblyResolver.cs | 2 +- .../ReferenceAssemblyPathResolver.cs | 4 +- .../Resolution/ResolverUtils.cs | 4 +- .../RuntimeLibrary.cs | 10 +- .../DependencyContextBuilderTests.cs | 177 +++++++++--------- .../DependencyContextCsvReaderTests.cs | 4 +- .../DependencyContextJsonReaderTest.cs | 22 +-- .../DependencyContextJsonWriterTests.cs | 3 +- .../PackageCacheResolverTest.cs | 4 +- .../PackageResolverTest.cs | 2 +- .../ReferenceAssemblyResolverTests.cs | 2 +- 19 files changed, 159 insertions(+), 156 deletions(-) diff --git a/TestAssets/TestProjects/DependencyContextValidator/DependencyContextValidator/Validator.cs b/TestAssets/TestProjects/DependencyContextValidator/DependencyContextValidator/Validator.cs index 81d057a29..0cfe83ce7 100644 --- a/TestAssets/TestProjects/DependencyContextValidator/DependencyContextValidator/Validator.cs +++ b/TestAssets/TestProjects/DependencyContextValidator/DependencyContextValidator/Validator.cs @@ -17,13 +17,13 @@ namespace Microsoft.Extensions.DependencyModel private static void CheckMetadata(Library library) { - if (string.Equals(library.LibraryType, "package", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase)) { - if (string.IsNullOrWhiteSpace(library.PackageName) || + if (string.IsNullOrWhiteSpace(library.Name) || string.IsNullOrWhiteSpace(library.Hash) || string.IsNullOrWhiteSpace(library.Version)) { - Error($"Empty metadata for {library.GetType().ToString()} {library.PackageName}"); + Error($"Empty metadata for {library.GetType().ToString()} {library.Name}"); } } } diff --git a/src/Microsoft.Extensions.DependencyModel/CompilationLibrary.cs b/src/Microsoft.Extensions.DependencyModel/CompilationLibrary.cs index 73ad8187b..1d5490f0f 100644 --- a/src/Microsoft.Extensions.DependencyModel/CompilationLibrary.cs +++ b/src/Microsoft.Extensions.DependencyModel/CompilationLibrary.cs @@ -9,8 +9,8 @@ namespace Microsoft.Extensions.DependencyModel { public class CompilationLibrary : Library { - public CompilationLibrary(string libraryType, string packageName, string version, string hash, string[] assemblies, Dependency[] dependencies, bool serviceable) - : base(libraryType, packageName, version, hash, dependencies, serviceable) + public CompilationLibrary(string type, string name, string version, string hash, string[] assemblies, Dependency[] dependencies, bool serviceable) + : base(type, name, version, hash, dependencies, serviceable) { Assemblies = assemblies; } @@ -30,7 +30,7 @@ namespace Microsoft.Extensions.DependencyModel var assemblies = new List(); if (!DefaultResolver.TryResolveAssemblyPaths(this, assemblies)) { - throw new InvalidOperationException($"Can not find compilation library location for package '{PackageName}'"); + throw new InvalidOperationException($"Can not find compilation library location for package '{Name}'"); } return assemblies; } diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs index 1aa81cce5..229a090b9 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.DependencyModel private static readonly Lazy _defaultContext = new Lazy(LoadDefault); - public DependencyContext(string target, + public DependencyContext(string targetFramework, string runtime, bool isPortable, CompilationOptions compilationOptions, @@ -24,9 +24,9 @@ namespace Microsoft.Extensions.DependencyModel IEnumerable runtimeLibraries, IEnumerable> runtimeGraph) { - if (target == null) + if (targetFramework == null) { - throw new ArgumentNullException(nameof(target)); + throw new ArgumentNullException(nameof(targetFramework)); } if (runtime == null) { @@ -49,7 +49,7 @@ namespace Microsoft.Extensions.DependencyModel throw new ArgumentNullException(nameof(runtimeGraph)); } - Target = target; + TargetFramework = targetFramework; Runtime = runtime; IsPortable = isPortable; CompilationOptions = compilationOptions; @@ -60,7 +60,7 @@ namespace Microsoft.Extensions.DependencyModel public static DependencyContext Default => _defaultContext.Value; - public string Target { get; } + public string TargetFramework { get; } public string Runtime { get; } diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContextCsvReader.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContextCsvReader.cs index db2ab933c..8008fe065 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContextCsvReader.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContextCsvReader.cs @@ -42,8 +42,8 @@ namespace Microsoft.Extensions.DependencyModel { var identity = packageGroup.Key; runtimeLibraries.Add(new RuntimeLibrary( - libraryType: identity.Item1, - packageName: identity.Item2, + type: identity.Item1, + name: identity.Item2, version: identity.Item3, hash: identity.Item4, assemblies: packageGroup.Select(l => RuntimeAssembly.Create(l.AssetPath)).ToArray(), @@ -54,7 +54,7 @@ namespace Microsoft.Extensions.DependencyModel } return new DependencyContext( - target: string.Empty, + targetFramework: string.Empty, runtime: string.Empty, isPortable: false, compilationOptions: CompilationOptions.Default, diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs index 3a5b014a9..88be796f4 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs @@ -39,8 +39,8 @@ namespace Microsoft.Extensions.DependencyModel private JObject WriteRuntimeTargetInfo(DependencyContext context) { var target = context.IsPortable? - context.Target : - context.Target + DependencyContextStrings.VersionSeperator + context.Runtime; + context.TargetFramework : + context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime; return new JObject( new JProperty(DependencyContextStrings.RuntimeTargetNamePropertyName, target), @@ -51,7 +51,7 @@ namespace Microsoft.Extensions.DependencyModel private JObject WriteRuntimeGraph(DependencyContext context) { return new JObject( - new JProperty(context.Target, + new JProperty(context.TargetFramework, new JObject( context.RuntimeGraph.Select(g => new JProperty(g.Key, new JArray(g.Value))) ) @@ -76,6 +76,7 @@ namespace Microsoft.Extensions.DependencyModel AddPropertyIfNotNull(o, DependencyContextStrings.PublicSignPropertyName, compilationOptions.PublicSign); AddPropertyIfNotNull(o, DependencyContextStrings.EmitEntryPointPropertyName, compilationOptions.EmitEntryPoint); AddPropertyIfNotNull(o, DependencyContextStrings.GenerateXmlDocumentationPropertyName, compilationOptions.GenerateXmlDocumentation); + AddPropertyIfNotNull(o, DependencyContextStrings.DebugTypePropertyName, compilationOptions.DebugType); return o; } @@ -92,13 +93,13 @@ namespace Microsoft.Extensions.DependencyModel if (context.IsPortable) { return new JObject( - new JProperty(context.Target, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries)) + new JProperty(context.TargetFramework, WritePortableTarget(context.RuntimeLibraries, context.CompileLibraries)) ); } return new JObject( - new JProperty(context.Target, WriteTarget(context.CompileLibraries)), - new JProperty(context.Target + DependencyContextStrings.VersionSeperator + context.Runtime, + new JProperty(context.TargetFramework, WriteTarget(context.CompileLibraries)), + new JProperty(context.TargetFramework + DependencyContextStrings.VersionSeperator + context.Runtime, WriteTarget(context.RuntimeLibraries)) ); } @@ -107,13 +108,13 @@ namespace Microsoft.Extensions.DependencyModel { return new JObject( libraries.Select(library => - new JProperty(library.PackageName + DependencyContextStrings.VersionSeperator + library.Version, WriteTargetLibrary(library)))); + new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version, WriteTargetLibrary(library)))); } private JObject WritePortableTarget(IReadOnlyList runtimeLibraries, IReadOnlyList compilationLibraries) { - var runtimeLookup = runtimeLibraries.ToDictionary(l => l.PackageName); - var compileLookup = compilationLibraries.ToDictionary(l => l.PackageName); + var runtimeLookup = runtimeLibraries.ToDictionary(l => l.Name); + var compileLookup = compilationLibraries.ToDictionary(l => l.Name); var targetObject = new JObject(); @@ -130,12 +131,12 @@ namespace Microsoft.Extensions.DependencyModel Debug.Assert(compilationLibrary.Serviceable == runtimeLibrary.Serviceable); Debug.Assert(compilationLibrary.Version == runtimeLibrary.Version); Debug.Assert(compilationLibrary.Hash == runtimeLibrary.Hash); - Debug.Assert(compilationLibrary.LibraryType == runtimeLibrary.LibraryType); + Debug.Assert(compilationLibrary.Type == runtimeLibrary.Type); } var library = (Library)compilationLibrary ?? (Library)runtimeLibrary; targetObject.Add( - new JProperty(library.PackageName + DependencyContextStrings.VersionSeperator + library.Version, + new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version, WritePortableTargetLibrary(runtimeLibrary, compilationLibrary) ) ); @@ -187,11 +188,11 @@ namespace Microsoft.Extensions.DependencyModel libraryObject.Add(new JProperty(DependencyContextStrings.RuntimeAssembliesKey, WriteAssemblies(runtimeLibrary.Assemblies.Select(a => a.Path))) ); - if (runtimeLibrary.SubTargets.Any()) + if (runtimeLibrary.RuntimeTargets.Any()) { libraryObject.Add(new JProperty( DependencyContextStrings.RuntimeTargetsPropertyName, - new JObject(runtimeLibrary.SubTargets.SelectMany(WriteRuntimeTarget))) + new JObject(runtimeLibrary.RuntimeTargets.SelectMany(WriteRuntimeTarget))) ); } @@ -256,7 +257,7 @@ namespace Microsoft.Extensions.DependencyModel { var allLibraries = context.RuntimeLibraries.Cast().Concat(context.CompileLibraries) - .GroupBy(library => library.PackageName + DependencyContextStrings.VersionSeperator + library.Version); + .GroupBy(library => library.Name + DependencyContextStrings.VersionSeperator + library.Version); return new JObject(allLibraries.Select(libraries=> new JProperty(libraries.Key, WriteLibrary(libraries.First())))); } @@ -264,7 +265,7 @@ namespace Microsoft.Extensions.DependencyModel private JObject WriteLibrary(Library library) { return new JObject( - new JProperty(DependencyContextStrings.TypePropertyName, library.LibraryType), + new JProperty(DependencyContextStrings.TypePropertyName, library.Type), new JProperty(DependencyContextStrings.ServiceablePropertyName, library.Serviceable), new JProperty(DependencyContextStrings.Sha512PropertyName, library.Hash) ); diff --git a/src/Microsoft.Extensions.DependencyModel/Library.cs b/src/Microsoft.Extensions.DependencyModel/Library.cs index 1dcd2b169..74c5cc2ef 100644 --- a/src/Microsoft.Extensions.DependencyModel/Library.cs +++ b/src/Microsoft.Extensions.DependencyModel/Library.cs @@ -7,19 +7,19 @@ namespace Microsoft.Extensions.DependencyModel { public class Library { - public Library(string libraryType, string packageName, string version, string hash, Dependency[] dependencies, bool serviceable) + public Library(string type, string name, string version, string hash, Dependency[] dependencies, bool serviceable) { - LibraryType = libraryType; - PackageName = packageName; + Type = type; + Name = name; Version = version; Hash = hash; Dependencies = dependencies; Serviceable = serviceable; } - public string LibraryType { get; } + public string Type { get; } - public string PackageName { get; } + public string Name { get; } public string Version { get; } diff --git a/src/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs b/src/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs index f5f681f86..9c047365f 100644 --- a/src/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs +++ b/src/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs @@ -37,11 +37,11 @@ namespace Microsoft.Extensions.DependencyModel.Resolution public bool TryResolveAssemblyPaths(CompilationLibrary library, List assemblies) { - var isProject = string.Equals(library.LibraryType, "project", StringComparison.OrdinalIgnoreCase); + var isProject = string.Equals(library.Type, "project", StringComparison.OrdinalIgnoreCase); if (!isProject && - !string.Equals(library.LibraryType, "package", StringComparison.OrdinalIgnoreCase) && - !string.Equals(library.LibraryType, "referenceassembly", StringComparison.OrdinalIgnoreCase)) + !string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase) && + !string.Equals(library.Type, "referenceassembly", StringComparison.OrdinalIgnoreCase)) { return false; } diff --git a/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCacheCompilationAssemblyResolver.cs b/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCacheCompilationAssemblyResolver.cs index 2b955b0c1..156ea0622 100644 --- a/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCacheCompilationAssemblyResolver.cs +++ b/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCacheCompilationAssemblyResolver.cs @@ -36,7 +36,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution public bool TryResolveAssemblyPaths(CompilationLibrary library, List assemblies) { - if (!string.Equals(library.LibraryType, "package", StringComparison.OrdinalIgnoreCase)) + if (!string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase)) { return false; } @@ -46,14 +46,14 @@ namespace Microsoft.Extensions.DependencyModel.Resolution var hashSplitterPos = library.Hash.IndexOf('-'); if (hashSplitterPos <= 0 || hashSplitterPos == library.Hash.Length - 1) { - throw new InvalidOperationException($"Invalid hash entry '{library.Hash}' for package '{library.PackageName}'"); + throw new InvalidOperationException($"Invalid hash entry '{library.Hash}' for package '{library.Name}'"); } string packagePath; if (ResolverUtils.TryResolvePackagePath(_fileSystem, library, _packageCacheDirectory, out packagePath)) { var hashAlgorithm = library.Hash.Substring(0, hashSplitterPos); - var cacheHashPath = Path.Combine(packagePath, $"{library.PackageName}.{library.Version}.nupkg.{hashAlgorithm}"); + var cacheHashPath = Path.Combine(packagePath, $"{library.Name}.{library.Version}.nupkg.{hashAlgorithm}"); if (_fileSystem.File.Exists(cacheHashPath) && _fileSystem.File.ReadAllText(cacheHashPath) == library.Hash.Substring(hashSplitterPos + 1)) diff --git a/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs b/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs index 4f4928473..680d24e99 100644 --- a/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs +++ b/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCompilationAssemblyResolver.cs @@ -65,7 +65,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution public bool TryResolveAssemblyPaths(CompilationLibrary library, List assemblies) { if (string.IsNullOrEmpty(_nugetPackageDirectory) || - !string.Equals(library.LibraryType, "package", StringComparison.OrdinalIgnoreCase)) + !string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase)) { return false; } diff --git a/src/Microsoft.Extensions.DependencyModel/Resolution/ReferenceAssemblyPathResolver.cs b/src/Microsoft.Extensions.DependencyModel/Resolution/ReferenceAssemblyPathResolver.cs index 53a36abdb..523b20eca 100644 --- a/src/Microsoft.Extensions.DependencyModel/Resolution/ReferenceAssemblyPathResolver.cs +++ b/src/Microsoft.Extensions.DependencyModel/Resolution/ReferenceAssemblyPathResolver.cs @@ -41,7 +41,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution public bool TryResolveAssemblyPaths(CompilationLibrary library, List assemblies) { - if (!string.Equals(library.LibraryType, "referenceassembly", StringComparison.OrdinalIgnoreCase)) + if (!string.Equals(library.Type, "referenceassembly", StringComparison.OrdinalIgnoreCase)) { return false; } @@ -50,7 +50,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution string fullName; if (!TryResolveReferenceAssembly(assembly, out fullName)) { - throw new InvalidOperationException($"Can not find reference assembly '{assembly}' file for package {library.PackageName}"); + throw new InvalidOperationException($"Can not find reference assembly '{assembly}' file for package {library.Name}"); } assemblies.Add(fullName); } diff --git a/src/Microsoft.Extensions.DependencyModel/Resolution/ResolverUtils.cs b/src/Microsoft.Extensions.DependencyModel/Resolution/ResolverUtils.cs index bfcf7f44f..b9b93d276 100644 --- a/src/Microsoft.Extensions.DependencyModel/Resolution/ResolverUtils.cs +++ b/src/Microsoft.Extensions.DependencyModel/Resolution/ResolverUtils.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution { internal static bool TryResolvePackagePath(IFileSystem fileSystem, CompilationLibrary library, string basePath, out string packagePath) { - packagePath = Path.Combine(basePath, library.PackageName, library.Version); + packagePath = Path.Combine(basePath, library.Name, library.Version); if (fileSystem.Directory.Exists(packagePath)) { return true; @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution string fullName; if (!TryResolveAssemblyFile(fileSystem, basePath, assembly, out fullName)) { - throw new InvalidOperationException($"Can not find assembly file for package {library.PackageName} at '{fullName}'"); + throw new InvalidOperationException($"Can not find assembly file for package {library.Name} at '{fullName}'"); } yield return fullName; } diff --git a/src/Microsoft.Extensions.DependencyModel/RuntimeLibrary.cs b/src/Microsoft.Extensions.DependencyModel/RuntimeLibrary.cs index ad5aaae85..4519e8590 100644 --- a/src/Microsoft.Extensions.DependencyModel/RuntimeLibrary.cs +++ b/src/Microsoft.Extensions.DependencyModel/RuntimeLibrary.cs @@ -9,22 +9,22 @@ namespace Microsoft.Extensions.DependencyModel public class RuntimeLibrary : Library { public RuntimeLibrary( - string libraryType, - string packageName, + string type, + string name, string version, string hash, RuntimeAssembly[] assemblies, RuntimeTarget[] subTargets, Dependency[] dependencies, bool serviceable) - : base(libraryType, packageName, version, hash, dependencies, serviceable) + : base(type, name, version, hash, dependencies, serviceable) { Assemblies = assemblies; - SubTargets = subTargets; + RuntimeTargets = subTargets; } public IReadOnlyList Assemblies { get; } - public IReadOnlyList SubTargets { get; } + public IReadOnlyList RuntimeTargets { get; } } } \ No newline at end of file diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextBuilderTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextBuilderTests.cs index d62013fa9..13eaefaa0 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextBuilderTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextBuilderTests.cs @@ -68,87 +68,12 @@ namespace Microsoft.Extensions.DependencyModel.Tests context.CompilationOptions.Platform.Should().Be("Platform"); } - - private LibraryExport Export( - LibraryDescription description, - IEnumerable compilationAssemblies = null, - IEnumerable runtimeAssemblies = null) - { - return new LibraryExport( - description, - compilationAssemblies ?? Enumerable.Empty(), - Enumerable.Empty(), - runtimeAssemblies ?? Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty() - ); - } - - private PackageDescription PackageDescription( - string name = null, - NuGetVersion version = null, - string hash = null, - IEnumerable dependencies = null, - bool? servicable = null) - { - return new PackageDescription( - "PATH", - new LockFilePackageLibrary() - { - Files = new string[] { }, - IsServiceable = servicable ?? false, - Name = name ?? _defaultName, - Version = version ?? _defaultVersion, - Sha512 = hash ?? _defaultHash - }, - new LockFileTargetLibrary(), - dependencies ?? Enumerable.Empty(), - true); - } - - private ProjectDescription ProjectDescription( - string name = null, - NuGetVersion version = null, - IEnumerable dependencies = null) - { - return new ProjectDescription( - new LibraryRange( - name ?? _defaultName, - new VersionRange(version ?? _defaultVersion), - LibraryType.Project, - LibraryDependencyType.Default - ), - new Project(), - dependencies ?? Enumerable.Empty(), - new TargetFrameworkInformation(), - true); - } - - private LibraryDescription ReferenceAssemblyDescription( - string name = null, - NuGetVersion version = null) - { - return new LibraryDescription( - new LibraryIdentity( - name ?? _defaultName, - version ?? _defaultVersion, - LibraryType.ReferenceAssembly), - string.Empty, // Framework assemblies don't have hashes - "PATH", - Enumerable.Empty(), - _defaultFramework, - true, - true); - } - [Fact] public void FillsRuntimeAndTarget() { - var context = Build(target: new NuGetFramework("SomeFramework",new Version(1,2)), runtime: "win8-32"); - context.Runtime.Should().Be("win8-32"); - context.Target.Should().Be("SomeFramework,Version=v1.2"); + var context = Build(target: new NuGetFramework("SomeFramework",new Version(1,2)), runtime: "win8-x86"); + context.Runtime.Should().Be("win8-x86"); + context.TargetFramework.Should().Be("SomeFramework,Version=v1.2"); } [Fact] @@ -194,16 +119,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests context.RuntimeLibraries.Should().HaveCount(2); - var lib = context.RuntimeLibraries.Should().Contain(l => l.PackageName == "Pack.Age").Subject; - lib.LibraryType.Should().Be("package"); + var lib = context.RuntimeLibraries.Should().Contain(l => l.Name == "Pack.Age").Subject; + lib.Type.Should().Be("package"); lib.Serviceable.Should().BeTrue(); lib.Hash.Should().Be("sha512-Hash"); lib.Version.Should().Be("1.2.3"); lib.Dependencies.Should().OnlyContain(l => l.Name == "System.Collections" && l.Version == "3.3.3"); lib.Assemblies.Should().OnlyContain(l => l.Path == "lib/Pack.Age.dll"); - var asm = context.RuntimeLibraries.Should().Contain(l => l.PackageName == "System.Collections").Subject; - asm.LibraryType.Should().Be("referenceassembly"); + var asm = context.RuntimeLibraries.Should().Contain(l => l.Name == "System.Collections").Subject; + asm.Type.Should().Be("referenceassembly"); asm.Version.Should().Be("3.3.3"); asm.Hash.Should().BeEmpty(); asm.Dependencies.Should().BeEmpty(); @@ -242,16 +167,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests context.CompileLibraries.Should().HaveCount(2); - var lib = context.CompileLibraries.Should().Contain(l => l.PackageName == "Pack.Age").Subject; - lib.LibraryType.Should().Be("package"); + var lib = context.CompileLibraries.Should().Contain(l => l.Name == "Pack.Age").Subject; + lib.Type.Should().Be("package"); lib.Serviceable.Should().BeTrue(); lib.Hash.Should().Be("sha512-Hash"); lib.Version.Should().Be("1.2.3"); lib.Dependencies.Should().OnlyContain(l => l.Name == "System.Collections" && l.Version == "3.3.3"); lib.Assemblies.Should().OnlyContain(a => a == "lib/Pack.Age.dll"); - var asm = context.CompileLibraries.Should().Contain(l => l.PackageName == "System.Collections").Subject; - asm.LibraryType.Should().Be("referenceassembly"); + var asm = context.CompileLibraries.Should().Contain(l => l.Name == "System.Collections").Subject; + asm.Type.Should().Be("referenceassembly"); asm.Version.Should().Be("3.3.3"); asm.Hash.Should().BeEmpty(); asm.Dependencies.Should().BeEmpty(); @@ -271,7 +196,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests }) }); - var asm = context.CompileLibraries.Should().Contain(l => l.PackageName == "System.Collections").Subject; + var asm = context.CompileLibraries.Should().Contain(l => l.Name == "System.Collections").Subject; asm.Assemblies.Should().OnlyContain(a => a == Path.Combine("sub", "System.Collections.dll")); } @@ -293,9 +218,85 @@ namespace Microsoft.Extensions.DependencyModel.Tests version: new NuGetVersion(3, 3, 3))) }); - var lib = context.CompileLibraries.Should().Contain(l => l.PackageName == "Pack.Age").Subject; + var lib = context.CompileLibraries.Should().Contain(l => l.Name == "Pack.Age").Subject; lib.Dependencies.Should().BeEmpty(); } + private LibraryExport Export( + LibraryDescription description, + IEnumerable compilationAssemblies = null, + IEnumerable runtimeAssemblies = null) + { + return new LibraryExport( + description, + compilationAssemblies ?? Enumerable.Empty(), + Enumerable.Empty(), + runtimeAssemblies ?? Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty() + ); + } + + private PackageDescription PackageDescription( + string name = null, + NuGetVersion version = null, + string hash = null, + IEnumerable dependencies = null, + bool? servicable = null) + { + return new PackageDescription( + "PATH", + new LockFilePackageLibrary() + { + Files = new string[] { }, + IsServiceable = servicable ?? false, + Name = name ?? _defaultName, + Version = version ?? _defaultVersion, + Sha512 = hash ?? _defaultHash + }, + new LockFileTargetLibrary(), + dependencies ?? Enumerable.Empty(), + true, + true); + } + + private ProjectDescription ProjectDescription( + string name = null, + NuGetVersion version = null, + IEnumerable dependencies = null) + { + return new ProjectDescription( + new LibraryRange( + name ?? _defaultName, + new VersionRange(version ?? _defaultVersion), + LibraryType.Project, + LibraryDependencyType.Default + ), + new Project(), + dependencies ?? Enumerable.Empty(), + new TargetFrameworkInformation(), + true); + } + + private LibraryDescription ReferenceAssemblyDescription( + string name = null, + NuGetVersion version = null) + { + return new LibraryDescription( + new LibraryIdentity( + name ?? _defaultName, + version ?? _defaultVersion, + LibraryType.ReferenceAssembly), + string.Empty, // Framework assemblies don't have hashes + "PATH", + Enumerable.Empty(), + _defaultFramework, + true, + true); + } + + } } diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextCsvReaderTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextCsvReaderTests.cs index e5ebe1a3c..7c19c1c69 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextCsvReaderTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextCsvReaderTests.cs @@ -32,8 +32,8 @@ namespace Microsoft.Extensions.DependencyModel.Tests "); context.RuntimeLibraries.Should().HaveCount(1); var library = context.RuntimeLibraries.Single(); - library.LibraryType.Should().Be("Package"); - library.PackageName.Should().Be("runtime.any.System.AppContext"); + library.Type.Should().Be("Package"); + library.Name.Should().Be("runtime.any.System.AppContext"); library.Version.Should().Be("4.1.0-rc2-23811"); library.Hash.Should().Be("sha512-1"); library.Assemblies.Should().HaveCount(2).And diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonReaderTest.cs b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonReaderTest.cs index 375a22bda..4a34baf92 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonReaderTest.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonReaderTest.cs @@ -34,7 +34,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests } }"); context.IsPortable.Should().BeFalse(); - context.Target.Should().Be(".NETStandardApp,Version=v1.5"); + context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5"); context.Runtime.Should().Be("osx.10.10-x64"); } @@ -56,7 +56,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests "".NETStandardApp,Version=v1.5"": {} } }"); - context.Target.Should().Be(".NETStandardApp,Version=v1.5"); + context.TargetFramework.Should().Be(".NETStandardApp,Version=v1.5"); } [Fact] @@ -119,16 +119,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests } }"); context.CompileLibraries.Should().HaveCount(2); - var project = context.CompileLibraries.Should().Contain(l => l.PackageName == "MyApp").Subject; + var project = context.CompileLibraries.Should().Contain(l => l.Name == "MyApp").Subject; project.Version.Should().Be("1.0.1"); project.Assemblies.Should().BeEquivalentTo("MyApp.dll"); - project.LibraryType.Should().Be("project"); + project.Type.Should().Be("project"); - var package = context.CompileLibraries.Should().Contain(l => l.PackageName == "System.Banana").Subject; + var package = context.CompileLibraries.Should().Contain(l => l.Name == "System.Banana").Subject; package.Version.Should().Be("1.0.0"); package.Assemblies.Should().BeEquivalentTo("ref/dotnet5.4/System.Banana.dll"); package.Hash.Should().Be("HASH-System.Banana"); - package.LibraryType.Should().Be("package"); + package.Type.Should().Be("package"); package.Serviceable.Should().Be(false); } @@ -178,20 +178,20 @@ namespace Microsoft.Extensions.DependencyModel.Tests } }"); context.CompileLibraries.Should().HaveCount(2); - var project = context.RuntimeLibraries.Should().Contain(l => l.PackageName == "MyApp").Subject; + var project = context.RuntimeLibraries.Should().Contain(l => l.Name == "MyApp").Subject; project.Version.Should().Be("1.0.1"); project.Assemblies.Should().Contain(a => a.Path == "MyApp.dll"); - project.LibraryType.Should().Be("project"); + project.Type.Should().Be("project"); - var package = context.RuntimeLibraries.Should().Contain(l => l.PackageName == "System.Banana").Subject; + var package = context.RuntimeLibraries.Should().Contain(l => l.Name == "System.Banana").Subject; package.Version.Should().Be("1.0.0"); package.Hash.Should().Be("HASH-System.Banana"); - package.LibraryType.Should().Be("package"); + package.Type.Should().Be("package"); package.Serviceable.Should().Be(false); package.Assemblies.Should().Contain(a => a.Path == "lib/dotnet5.4/System.Banana.dll"); - var target = package.SubTargets.Should().Contain(t => t.Runtime == "win7-x64").Subject; + var target = package.RuntimeTargets.Should().Contain(t => t.Runtime == "win7-x64").Subject; target.Assemblies.Should().Contain(a => a.Path == "lib/win7/System.Banana.dll"); target.NativeLibraries.Should().Contain("lib/win7/Banana.dll"); } diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs index 3f69c3cc8..fb5c79355 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs @@ -169,7 +169,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests "HASH", new [] { RuntimeAssembly.Create("Banana.dll")}, new [] - { + {Lock new RuntimeTarget("win7-x64", new [] { RuntimeAssembly.Create("Banana.Win7-x64.dll") }, new [] { "Banana.Win7-x64.so" } @@ -334,6 +334,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests optimize: true, keyFile: "Key.snk", delaySign: true, + debugType: null, publicSign: true, emitEntryPoint: true, generateXmlDocumentation: true))); diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/PackageCacheResolverTest.cs b/test/Microsoft.Extensions.DependencyModel.Tests/PackageCacheResolverTest.cs index c3879fcf3..7ea550b98 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/PackageCacheResolverTest.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/PackageCacheResolverTest.cs @@ -49,7 +49,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests var exception = Assert.Throws(() => resolver.TryResolveAssemblyPaths(library, null)); exception.Message.Should() .Contain(library.Hash) - .And.Contain(library.PackageName); + .And.Contain(library.Name); } [Fact] @@ -114,7 +114,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests var exception = Assert.Throws(() => resolver.TryResolveAssemblyPaths(library, assemblies)); exception.Message.Should() .Contain(F.SecondAssemblyPath) - .And.Contain(library.PackageName); + .And.Contain(library.Name); } private IEnvironment GetDefaultEnviroment() diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/PackageResolverTest.cs b/test/Microsoft.Extensions.DependencyModel.Tests/PackageResolverTest.cs index 35869d7fc..2eb0e095f 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/PackageResolverTest.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/PackageResolverTest.cs @@ -95,7 +95,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests var exception = Assert.Throws(() => resolver.TryResolveAssemblyPaths(library, assemblies)); exception.Message.Should() .Contain(F.SecondAssemblyPath) - .And.Contain(library.PackageName); + .And.Contain(library.Name); } } } diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/ReferenceAssemblyResolverTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/ReferenceAssemblyResolverTests.cs index 9af3e0abf..7561c77dc 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/ReferenceAssemblyResolverTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/ReferenceAssemblyResolverTests.cs @@ -153,7 +153,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests exception.Message.Should() .Contain(F.SecondAssemblyPath) - .And.Contain(library.PackageName); + .And.Contain(library.Name); } } }