Esempio n. 1
0
 public AzureDtoAssemblyReference(IPackageAssemblyReference assemblyReference)
 {
     Name = assemblyReference.Name;
     TargetFrameworkString = assemblyReference.TargetFramework.ToString();
     EffectivePath = assemblyReference.EffectivePath;
     PathStr = assemblyReference.Path;
     SupportedFrameworkStrs = assemblyReference.SupportedFrameworks.Select(x => x.ToString());
 }
Esempio n. 2
0
 public AzureDtoAssemblyReference(IPackageAssemblyReference assemblyReference)
 {
     Name = assemblyReference.Name;
     TargetFrameworkString = assemblyReference.TargetFramework.ToString();
     EffectivePath         = assemblyReference.EffectivePath;
     PathStr = assemblyReference.Path;
     SupportedFrameworkStrs = assemblyReference.SupportedFrameworks.Select(x => x.ToString());
 }
Esempio n. 3
0
        public void GetCompatibleReferencesReturnsNullIfNoBestMatchFound()
        {
            // Arrange
            var assemblyReference  = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("5.0")));
            var assemblyReferences = new IPackageAssemblyReference[] { assemblyReference };

            // Act
            var compatibleAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("3.5")), assemblyReferences);

            // Assert
            Assert.Null(compatibleAssemblyReferences);
        }
Esempio n. 4
0
        public void GetCompatibleReferencesNoProjectFrameworkSpecified()
        {
            // Arrange
            var assemblyReference = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("5.0")));
            var assemblyReferenceNullFrameworkName = PackageUtility.CreateAssemblyReference("foo2.dll", null);
            var assemblyReferences = new IPackageAssemblyReference[] { assemblyReference, assemblyReferenceNullFrameworkName };

            // Act
            var compatibleAssemblyReferences = GetCompatibleItems(null, assemblyReferences).ToList();

            // Assert
            Assert.Equal(1, compatibleAssemblyReferences.Count);
            Assert.Equal(assemblyReferenceNullFrameworkName, compatibleAssemblyReferences[0]);
        }
Esempio n. 5
0
        public void GetCompatibleReferencesPrefersMatchingProfileIfSpecified()
        {
            // Arrange
            var assemblyReferenceSL40phone = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName("Silverlight", new Version("4.0"), "WindowsPhone"));
            var assemblyReferenceSL40      = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName("Silverlight", new Version("4.0")));
            var assemblyReferences         = new IPackageAssemblyReference[] { assemblyReferenceSL40phone, assemblyReferenceSL40 };

            // Act
            var targetAssemblyReferences = GetCompatibleItems(new FrameworkName("Silverlight", new Version("4.0"), "WindowsPhone"), assemblyReferences)
                                           .ToList();

            // Assert
            Assert.Equal(1, targetAssemblyReferences.Count);
            Assert.Same(assemblyReferenceSL40phone, targetAssemblyReferences[0]);
        }
Esempio n. 6
0
        public void GetCompatibleReferencesMostSpecificFrameworkIfProfileNameSpecified()
        {
            // Arrange
            var assemblyReference30client  = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("3.0"), "Client"));
            var assemblyReference40        = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("4.0")));
            var assemblyReferenceNoVersion = PackageUtility.CreateAssemblyReference("foo.dll", null);
            var assemblyReferences         = new IPackageAssemblyReference[] { assemblyReference30client, assemblyReference40, assemblyReferenceNoVersion };

            // Act
            var compatibleAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("4.0"), "Client"), assemblyReferences).ToList();

            // Assert
            Assert.Equal(1, compatibleAssemblyReferences.Count);
            Assert.Equal(assemblyReference40, compatibleAssemblyReferences[0]);
        }
Esempio n. 7
0
        public void GetCompatibleReferencesReferenceWithUnspecifiedFrameworkNameWinsIfNoMatchingSpecificFrameworkNames()
        {
            // Arrange
            var assemblyReference20        = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("2.0")));
            var assemblyReference30        = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("3.0")));
            var assemblyReference40        = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("4.0")));
            var assemblyReferenceNoVersion = PackageUtility.CreateAssemblyReference("foo.dll", null);
            var assemblyReferences         = new IPackageAssemblyReference[] { assemblyReference20, assemblyReference30, assemblyReference40, assemblyReferenceNoVersion };

            // Act
            var targetAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("1.1")), assemblyReferences).ToList();

            // Assert
            Assert.Equal(1, targetAssemblyReferences.Count);
            Assert.Same(assemblyReferenceNoVersion, targetAssemblyReferences[0]);
        }
Esempio n. 8
0
        public void GetCompatibleReferencesPrefersMatchingProfile()
        {
            // Arrange
            var assemblyReference30client = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("3.0"), "client"));
            var assemblyReference40client = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("4.0"), "client"));
            var assemblyReference30       = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("3.0")));
            var assemblyReference40       = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("4.0")));
            var assemblyReferences        = new IPackageAssemblyReference[] { assemblyReference30client, assemblyReference40client, assemblyReference30, assemblyReference40 };

            // Act
            var targetAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("4.0")), assemblyReferences).ToList();

            // Assert
            Assert.Equal(1, targetAssemblyReferences.Count);
            Assert.Same(assemblyReference40, targetAssemblyReferences[0]);
        }
Esempio n. 9
0
        public void GetCompatibleReferencesPicksHigestVersionLessThanTargetVersion()
        {
            // Arrange
            var assemblyReference10 = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("1.0")));
            var assemblyReference20 = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("2.0")));
            var assemblyReference30 = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("3.0")));
            var assemblyReference40 = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("4.0")));
            var assemblyReferences  = new IPackageAssemblyReference[] { assemblyReference10, assemblyReference20, assemblyReference30, assemblyReference40 };

            // Act
            var targetAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("3.5")), assemblyReferences)
                                           .ToList();

            // Assert
            Assert.Equal(1, targetAssemblyReferences.Count);
            Assert.Same(assemblyReference30, targetAssemblyReferences[0]);
        }
Esempio n. 10
0
        public void GetCompatibleReferencesHighestSpecifiedAssemblyLessThanProjectTargetFrameworkWins()
        {
            // Arrange
            var assemblyReference10        = PackageUtility.CreateAssemblyReference("foo1.dll", new FrameworkName(".NETFramework", new Version("1.0")));
            var assemblyReference20        = PackageUtility.CreateAssemblyReference("foo1.dll", new FrameworkName(".NETFramework", new Version("2.0")));
            var assemblyReference30        = PackageUtility.CreateAssemblyReference("foo2.dll", new FrameworkName(".NETFramework", new Version("3.0")));
            var assemblyReference40        = PackageUtility.CreateAssemblyReference("foo2.dll", new FrameworkName(".NETFramework", new Version("4.0")));
            var assemblyReferenceNoVersion = PackageUtility.CreateAssemblyReference("foo3.dll", null);
            var assemblyReferences         = new IPackageAssemblyReference[] { assemblyReference10, assemblyReference20, assemblyReference30, assemblyReference40, assemblyReferenceNoVersion };

            // Act
            var compatibleAssemblyReferences = GetCompatibleItems(new FrameworkName(".NETFramework", new Version("3.5")), assemblyReferences).ToList();

            // Assert
            Assert.Equal(1, compatibleAssemblyReferences.Count);
            Assert.Equal(assemblyReference30, compatibleAssemblyReferences[0]);
        }
Esempio n. 11
0
        public void GetCompatibleReferencesReferenceWithUnspecifiedFrameworkNameWinsIfNoMatchingSpecificFrameworkNamesWithDifferentProfiles()
        {
            // Arrange
            var assemblyReference20         = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETFramework", new Version("2.0")));
            var assemblyReference30         = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName("Silverlight", new Version("3.0")));
            var assemblyReference40         = PackageUtility.CreateAssemblyReference("foo.dll", new FrameworkName(".NETCore", new Version("4.5")));
            var assemblyReferenceNoVersion  = PackageUtility.CreateAssemblyReference("foo.dll", null);
            var assemblyReferenceNoVersion2 = PackageUtility.CreateAssemblyReference("bar.dll", null);
            var assemblyReferences          = new IPackageAssemblyReference[] { assemblyReferenceNoVersion2, assemblyReference20, assemblyReference30, assemblyReference40, assemblyReferenceNoVersion };

            // Act
            var targetAssemblyReferences = GetCompatibleItems(new FrameworkName("WindowsPhone", new Version("8.0")), assemblyReferences).ToList();

            // Assert
            Assert.Equal(2, targetAssemblyReferences.Count);
            Assert.Same(assemblyReferenceNoVersion, targetAssemblyReferences[1]);
            Assert.Same(assemblyReferenceNoVersion2, targetAssemblyReferences[0]);
        }
 public string GetPath(IPackage package, IPackageAssemblyReference packageAssemblyReference)
 {
     return(Path.Combine(_pathResolver.GetInstallPath(package), packageAssemblyReference.Path));
 }
Esempio n. 13
0
		private Assembly LoadAssembly(IPackageAssemblyReference reference)
		{
			if(!referencedAssemblies.ContainsKey(reference.Name))
			{
				var assembly = Assembly.ReflectionOnlyLoad(reference.GetStream().ReadAllBytes());
				nodes.Add(assembly.ToGraphNode());
				referencedAssemblies.Add(reference.Name, assembly);
			}

			return referencedAssemblies[reference.Name];
		}
Esempio n. 14
0
		private static bool IsNonBclAssembly(IPackageAssemblyReference assemblyReference)
		{
			var name = assemblyReference.Name;
			return IsBclClassName(name);
		}