コード例 #1
0
        public void TestIsCompatibleWithFrameworkName()
        {
            // Arrange
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var fw1 = new FrameworkName(".NETFramework, Version=4.0");
            var fw2 = new FrameworkName(".NETFramework, Version=4.5");
            var fw3 = new FrameworkName("Silverlight, Version=3.0");
            var fw4 = new FrameworkName("Silverlight, Version=5.0");
            var fw5 = new FrameworkName("WindowsPhone, Version=8.0");
            var fw6 = new FrameworkName("WindowsPhone, Version=7.0");
            var fw7 = new FrameworkName(".NETCore, Version=4.5");

            // Act & Assert
            Assert.False(profile.IsCompatibleWith(fw1));
            Assert.True(profile.IsCompatibleWith(fw2));
            Assert.False(profile.IsCompatibleWith(fw3));
            Assert.True(profile.IsCompatibleWith(fw4));
            Assert.True(profile.IsCompatibleWith(fw5));
            Assert.False(profile.IsCompatibleWith(fw6));
            Assert.False(profile.IsCompatibleWith(fw7));
        }
コード例 #2
0
        public void TestIsCompatibleWithFrameworkName()
        {
            // Arrange
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var tc = new TestContext(packageProfile);
            var packageFramework = GetFrameworkName(packageProfile);

            var fw1 = new FrameworkName(".NETFramework, Version=4.0");
            var fw2 = new FrameworkName(".NETFramework, Version=4.5");
            var fw3 = new FrameworkName("Silverlight, Version=3.0");
            var fw4 = new FrameworkName("Silverlight, Version=5.0");
            var fw5 = new FrameworkName("WindowsPhone, Version=8.0");
            var fw6 = new FrameworkName("WindowsPhone, Version=7.0");
            var fw7 = new FrameworkName(".NETCore, Version=4.5");

            // Act & Assert
            tc.VerifyIsCompatible(fw1, packageFramework, false);
            tc.VerifyIsCompatible(fw2, packageFramework, true);
            tc.VerifyIsCompatible(fw3, packageFramework, false);
            tc.VerifyIsCompatible(fw4, packageFramework, true);
            tc.VerifyIsCompatible(fw5, packageFramework, true);
            tc.VerifyIsCompatible(fw6, packageFramework, false);
            tc.VerifyIsCompatible(fw7, packageFramework, false);
        }
コード例 #3
0
        public void TestIsCompatibleWithPortableProfile11WithMonoProjectWithVersionLesserThanInstalledProfile()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=1.0"),
                new FrameworkName("MonoAndroid, Version=2.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.0"),
                new FrameworkName("Windows, Version=8.0"),
            });

            var tc = new TestContext(profile1, packageProfile);

            var packageFramework = GetFrameworkName(packageProfile);
            var projectFramework = new FrameworkName("MonoAndroid, Version=1.0");

            // Act & Assert
            tc.VerifyIsCompatible(projectFramework, packageFramework, false);
        }
コード例 #4
0
        public void TestIsCompatibleWithPortableProfile8WithMono()
        {
            // Arrange
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
            });

            var projectProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=5.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=0.0"),
                new FrameworkName("MonoAndroid, Version=1.0"),
            });

            var tc = new TestContext(packageProfile, projectProfile);

            var packageFramework = GetFrameworkName(packageProfile);
            var projectFramework = GetFrameworkName(projectProfile);

            // Act & Assert
            tc.VerifyIsCompatible(projectFramework, packageFramework, true);
        }
コード例 #5
0
        public void TestParseWithStandardProfileString()
        {
            // Arrange & Act
            var profileCollection = new NetPortableProfileCollection();
            var profile1          = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NetCore, Version=4.5"),
                new FrameworkName("Silverlight, Version=3.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            profileCollection.Add(profile1);
            profileCollection.Add(profile2);

            NetPortableProfileTable.Profiles = profileCollection;

            var profile = NetPortableProfile.Parse("Profile2");

            // Assert
            Assert.Equal(3, profile.SupportedFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NetCore, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=3.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
        }
コード例 #6
0
        public void TestIsCompatibleWithPortableProfile4()
        {
            // Arrange
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var projectProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName(".NETCore, Version=4.0")
            });

            var tc = new TestContext(packageProfile, projectProfile);

            var packageFramework = GetFrameworkName(packageProfile);
            var projectFramework = GetFrameworkName(projectProfile);

            // Act & Assert
            tc.VerifyIsCompatible(projectFramework, packageFramework, false);
        }
コード例 #7
0
        public void TestIsCompatibleWithFrameworkName()
        {
            // Arrange 
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });

            var fw1 = new FrameworkName(".NETFramework, Version=4.0");
            var fw2 = new FrameworkName(".NETFramework, Version=4.5");
            var fw3 = new FrameworkName("Silverlight, Version=3.0");
            var fw4 = new FrameworkName("Silverlight, Version=5.0");
            var fw5 = new FrameworkName("WindowsPhone, Version=8.0");
            var fw6 = new FrameworkName("WindowsPhone, Version=7.0");
            var fw7 = new FrameworkName(".NETCore, Version=4.5");

            // Act & Assert
            Assert.False(profile.IsCompatibleWith(fw1));
            Assert.True(profile.IsCompatibleWith(fw2));
            Assert.False(profile.IsCompatibleWith(fw3));
            Assert.True(profile.IsCompatibleWith(fw4));
            Assert.True(profile.IsCompatibleWith(fw5));
            Assert.False(profile.IsCompatibleWith(fw6));
            Assert.False(profile.IsCompatibleWith(fw7));
        }
コード例 #8
0
 private static FrameworkName GetFrameworkName(NetPortableProfile profile)
 {
     return(new FrameworkName(
                ".NETPortable",
                new Version(profile.FrameworkVersion.Substring(1)), // "v0.0" becomes "0.0"
                profile.Name));
 }
コード例 #9
0
ファイル: FrameworkNameHelper.cs プロジェクト: yossidev/dnx
        public static FrameworkName ParseFrameworkName(string targetFramework)
        {
            if (targetFramework.Contains("+"))
            {
                var profile = targetFramework;
                if (targetFramework.StartsWith("portable-"))
                {
                    // Strip the "portable-" prefix before passing to the profile parser
                    profile = profile.Substring(9);
                }
                var portableProfile = NetPortableProfile.Parse(profile);

                // Only support it if it parsed to a real PCL number
                if (portableProfile != null &&
                    portableProfile.FrameworkName.Profile != profile)
                {
                    return(portableProfile.FrameworkName);
                }

                return(VersionUtility.UnsupportedFrameworkName);
            }

            if (targetFramework.IndexOf(',') != -1)
            {
                // Assume it's a framework name if it contains commas
                // e.g. .NETPortable,Version=v4.5,Profile=Profile78
                return(new FrameworkName(targetFramework));
            }

            return(VersionUtility.ParseFrameworkName(targetFramework));
        }
コード例 #10
0
        public void TestParseWithInvalidCustomProfileReturnsNull()
        {
            // Arrange & Act
            var profile = NetPortableProfile.Parse("Profile3284");

            // Assert
            Assert.Null(profile);
        }
コード例 #11
0
        public void TestIsCompatibleWithPortableProfile12WithMonoProjectWithMultipleInstalledProfileHavingMonoOfDifferentVersions()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=1.0"),
                new FrameworkName("MonoAndroid, Version=3.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoAndroid, Version=1.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            var profile3 = new NetPortableProfile(
                "Profile3",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.5"),
            },
                new[] {
                new FrameworkName("MonoAndroid, Version=3.0"),
            });

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.0"),
                new FrameworkName("Windows, Version=8.0"),
            });

            var tc = new TestContext(profile1, profile2, profile3, packageProfile);

            var packageFramework = GetFrameworkName(packageProfile);
            var projectFramework = new FrameworkName("MonoAndroid, Version=2.0");

            // Act & Assert
            tc.VerifyIsCompatible(projectFramework, packageFramework, true);
        }
コード例 #12
0
        public static bool Check(string profileValue)
        {
            profileValue = Regex.Replace(profileValue, @"wpa\+", "wpa81+");
            profileValue = Regex.Replace(profileValue, "wpa$", "wpa81");

            var profile = NetPortableProfile.Parse(profileValue);

            return(SupportedPclProfiles.Any(p => p.IsCompatibleWith(profile)));
        }
コード例 #13
0
        public void TestParseWithCustomProfileString2()
        {
            // Arrange & Act
            var profile = NetPortableProfile.Parse("wp7");

            // Assert
            Assert.Equal(1, profile.SupportedFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.0")));
        }
コード例 #14
0
        public void NamePropertyReturnsCorrectValue()
        {
            // Arrange
            var profile = new NetPortableProfile("ProfileXXX", new [] { new FrameworkName(".NETFramework, Version=4.5") });

            // Act
            string name = profile.Name;

            // Assert
            Assert.Equal("ProfileXXX", name);
        }
コード例 #15
0
        public void TestParseWithCustomProfileString1()
        {
            // Arrange & Act
            var profile = NetPortableProfile.Parse("sl3+net+netcore45");

            // Assert
            Assert.Equal(3, profile.SupportedFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=3.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=0.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETCore, Version=4.5")));
        }
コード例 #16
0
        public void NamePropertyReturnsCorrectValue()
        {
            // Arrange 
            var profile = new NetPortableProfile("ProfileXXX", new [] { new FrameworkName(".NETFramework, Version=4.5") });

            // Act
            string name = profile.Name;

            // Assert
            Assert.Equal("ProfileXXX", name);
        }
コード例 #17
0
        public void TestParseWithCustomProfileString3()
        {
            // Arrange & Act
            var profile = NetPortableProfile.Parse("wp71+win8+monoandroid1.6+monotouch1.0+sl4+net45");

            // Assert
            Assert.Equal(6, profile.SupportedFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Windows, Version=8.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoAndroid, Version=1.6")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=1.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
        }
コード例 #18
0
        public void SupportedFrameworksReturnsCorrectValue()
        {
            // Arrange 
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0") });

            // Act
            ISet<FrameworkName> frameworks = profile.SupportedFrameworks;

            // Assert
            Assert.Equal(2, frameworks.Count);
            Assert.True(frameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(frameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
        }
コード例 #19
0
        public void SupportedFrameworksReturnsCorrectValue()
        {
            // Arrange
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0") });

            // Act
            ISet <FrameworkName> frameworks = profile.SupportedFrameworks;

            // Assert
            Assert.Equal(2, frameworks.Count);
            Assert.True(frameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(frameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
        }
コード例 #20
0
        public void TestIsCompatibleWithPortableProfile7()
        {
            // Arrange
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName("WindowsPhone, Version=7.0"),
            });

            var targetProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            // Act & Assert
            Assert.True(profile.IsCompatibleWith(targetProfile));
        }
コード例 #21
0
        public void TestParseWithCustomProfileString5WithOptionalFrameworkAndTreatedAsOptional()
        {
            // Arrange
            var collection = new NetPortableProfileCollection();
            var profile1   = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=0.0"),
                new FrameworkName("MonoAndroid, Version=2.0"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NetCore, Version=4.5"),
                new FrameworkName("Silverlight, Version=3.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            collection.Add(profile1);
            collection.Add(profile2);

            var table = new NetPortableProfileTable(collection);

            // Act
            // Default value of second parameter treatOptionalFrameworksAsSupportedFrameworks is false
            var profile = NetPortableProfile.Parse(
                table,
                "net45+sl40+wp71+MonoTouch+MonoAndroid20");

            // Assert
            Assert.Equal(3, profile.SupportedFrameworks.Count);
            Assert.Equal(2, profile.OptionalFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
            Assert.True(profile.OptionalFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0")));
            Assert.True(profile.OptionalFrameworks.Contains(new FrameworkName("MonoAndroid, Version=2.0")));
        }
コード例 #22
0
        public void IsCompatible_SupportsCustomProfileName()
        {
            // Arrange
            var profile = new NetPortableProfile(
                "MyProfile",
                new[]  {
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var tc            = new TestContext(profile);
            var project       = new FrameworkName("Silverlight, Version=5.0");
            var compatible    = new FrameworkName(".NETPortable, Version=4.0, Profile=MyProfile");
            var notCompatible = new FrameworkName(".NETPortable, Version=4.0, Profile=YourProfile");

            // Act & Assert
            tc.VerifyIsCompatible(project, compatible, true);
            tc.VerifyIsCompatible(project, notCompatible, false);
        }
コード例 #23
0
        public void TestIsCompatibleWithPortableProfile5()
        {
            // Arrange
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
            });

            var targetProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName(".NETCore, Version=4.0")
            });

            // Act & Assert
            Assert.False(profile.IsCompatibleWith(targetProfile));
        }
コード例 #24
0
        public void TestParseWithCustomProfileString4WithDifferentOrderingOfFrameworks()
        {
            // Arrange
            var collection = new NetPortableProfileCollection();
            var profile1   = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=0.0"),
                new FrameworkName("MonoAndroid, Version=2.0"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NetCore, Version=4.5"),
                new FrameworkName("Silverlight, Version=3.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            collection.Add(profile1);
            collection.Add(profile2);

            var table = new NetPortableProfileTable(collection);

            // Act
            var profile = NetPortableProfile.Parse(
                table,
                "net45+sl40+MonoTouch+wp71+MonoAndroid20");

            // Assert
            Assert.Equal(5, profile.SupportedFrameworks.Count);
            Assert.Equal(0, profile.OptionalFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0")));
        }
コード例 #25
0
        static ManifestFile ManifestFileForAssembly(Assembly assembly, string path)
        {
            ManifestFile mf = new ManifestFile();

            AssemblyInfo ainfo = new AssemblyInfo(assembly);

            mf.Source = path;

            string version = "";

            if (string.IsNullOrEmpty(ainfo.TargetFramework))
            {
                if (assembly.ImageRuntimeVersion.StartsWith("v2.0"))
                {
                    version = "/net20";
                }
                if (assembly.ImageRuntimeVersion.StartsWith("v3.5"))
                {
                    version = "/net35";
                }
                if (assembly.ImageRuntimeVersion.StartsWith("v4.0"))
                {
                    version = "/net40";
                }
                if (assembly.ImageRuntimeVersion.StartsWith("v4.5"))
                {
                    version = "/net45";
                }
            }
            else
            {
                NetPortableProfile npp = new NetPortableProfile("test", new FrameworkName[1] {
                    new FrameworkName(ainfo.TargetFramework)
                });
                version = "/" + npp.CustomProfileString;
            }

            mf.Target = String.Format("lib{0}", version);

            return(mf);
        }
コード例 #26
0
        public void TestParseWithCustomProfileString6WithOptionalFrameworkAndTreatedAsSupported()
        {
            // Arrange & Act
            var profileCollection = new NetPortableProfileCollection();
            var profile1          = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=0.0"),
                new FrameworkName("MonoAndroid, Version=2.0"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NetCore, Version=4.5"),
                new FrameworkName("Silverlight, Version=3.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            profileCollection.Add(profile1);
            profileCollection.Add(profile2);

            NetPortableProfileTable.Profiles = profileCollection;

            var profile = NetPortableProfile.Parse("net45+sl40+wp71+MonoTouch+MonoAndroid20", treatOptionalFrameworksAsSupportedFrameworks: true);

            // Assert
            Assert.Equal(5, profile.SupportedFrameworks.Count);
            Assert.Equal(0, profile.OptionalFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0")));
        }
コード例 #27
0
        public void TestIsCompatibleWithPortableProfile1()
        {
            // Arrange 
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });

            var targetProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                           new FrameworkName(".NETFramework, Version=5.0"), 
                           new FrameworkName("Silverlight, Version=4.0")
                      });


            // Act & Assert
            Assert.True(profile.IsCompatibleWith(targetProfile));
        }
コード例 #28
0
        public void TestIsCompatibleWithPortableProfile7()
        {
            // Arrange
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName("WindowsPhone, Version=7.0"),
            });

            var projectProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName("WindowsPhone, Version=7.1"),
            });

            var tc = new TestContext(packageProfile, projectProfile);

            var packageFramework = GetFrameworkName(packageProfile);
            var projectFramework = GetFrameworkName(projectProfile);

            // Act & Assert
            tc.VerifyIsCompatible(projectFramework, packageFramework, true);
        }
コード例 #29
0
        public static IEnumerable <FrameworkName> Split(FrameworkName version)
        {
            if (!version.IsPortableFramework())
            {
                yield return(version);

                yield break;
            }

            var portable = NetPortableProfile.Parse(version.Profile);

            if (portable == null)
            {
                yield return(version);

                yield break;
            }

            foreach (var supportedVersion in portable.SupportedFrameworks)
            {
                yield return(supportedVersion);
            }
        }
コード例 #30
0
        public void TestIsCompatibleWithPortableProfile11WithMonoProjectWithVersionLesserThanInstalledProfile()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=1.0"),
                new FrameworkName("MonoAndroid, Version=2.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();

            profileCollection.Add(profile1);

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.0"),
                new FrameworkName("Windows, Version=8.0"),
            });

            var projectProfile = new FrameworkName("MonoAndroid, Version=1.0");

            NetPortableProfileTable.Profiles = profileCollection;

            // Act & Assert
            Assert.False(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #31
0
        public static FrameworkName ParseFrameworkName(string targetFramework)
        {
            if (targetFramework.Contains("+"))
            {
                var portableProfile = NetPortableProfile.Parse(targetFramework);

                if (portableProfile != null &&
                    portableProfile.FrameworkName.Profile != targetFramework)
                {
                    return(portableProfile.FrameworkName);
                }

                return(VersionUtility.UnsupportedFrameworkName);
            }

            if (targetFramework.IndexOf(',') != -1)
            {
                // Assume it's a framework name if it contains commas
                // e.g. .NETPortable,Version=v4.5,Profile=Profile78
                return(new FrameworkName(targetFramework));
            }

            return(VersionUtility.ParseFrameworkName(targetFramework));
        }
コード例 #32
0
        public void TestIsCompatibleWithPortableProfile8WithMono()
        {
            // Arrange
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
            });

            var projectProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=5.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=0.0"),
                new FrameworkName("MonoAndroid, Version=1.0"),
            });

            // Act & Assert
            Assert.True(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #33
0
        public void TestIsCompatibleWithPortableProfile8WithMono()
        {
            // Arrange 
            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName("Silverlight, Version=4.0"),                             
                      });

            var projectProfile = new NetPortableProfile(
               "MyProfile",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=5.0"), 
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=0.0"), 
                           new FrameworkName("MonoAndroid, Version=1.0"), 
                      });

            // Act & Assert
            Assert.True(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #34
0
ファイル: VersionUtilityTest.cs プロジェクト: Redth/nuget
        private NetPortableProfileCollection BuildProfileCollection()
        {
            var profileCollection = new NetPortableProfileCollection();
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NetCore, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=3.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });

            var profile3 = new NetPortableProfile(
               "Profile3",
               new[] { 
                           new FrameworkName(".NetCore, Version=4.5"), 
                           new FrameworkName(".NETFramework, Version=2.0"), 
                      });

            var profile4 = new NetPortableProfile(
               "Profile4",
               new[] { 
                           new FrameworkName("Silverlight, Version=2.0"), 
                           new FrameworkName("Silverlight, Version=3.0, Profile=WindowsPhone"), 
                      });

            profileCollection.Add(profile1);
            profileCollection.Add(profile2);
            profileCollection.Add(profile3);
            profileCollection.Add(profile4);

            return profileCollection;
        }
コード例 #35
0
ファイル: VersionUtilityTest.cs プロジェクト: Redth/nuget
        public void TestGetCompatibilityBetweenPortableLibraryAndNonPortableLibraryForMono(string projectFrameworkName, string packageTargetFrameworkName, long expectedScore)        
        {
            // Arrange
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.1"),
                           new FrameworkName("Windows, Version=8.0"),
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=1.0"), 
                           new FrameworkName("MonoAndroid, Version=1.0"),
                           new FrameworkName("MonoMac, Version=1.0"),
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("WindowsPhone, Version=8.0"),
                           new FrameworkName("Windows, Version=8.0"),
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=1.0"), 
                           new FrameworkName("MonoAndroid, Version=1.0"),
                      });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();
            profileCollection.Add(profile1);
            profileCollection.Add(profile2);

            NetPortableProfileTable.Profiles = profileCollection;

            // Arrange
            var framework = VersionUtility.ParseFrameworkName(projectFrameworkName);
            var targetFramework = VersionUtility.ParseFrameworkName(packageTargetFrameworkName);

            // Act
            long score = VersionUtility.GetCompatibilityBetweenPortableLibraryAndNonPortableLibrary(framework, targetFramework);

            // Assert
            Assert.Equal(expectedScore, score);
        }
コード例 #36
0
ファイル: VersionUtilityTest.cs プロジェクト: Redth/nuget
        public void TestGetCompatibilityBetweenPortableLibraryAndPortableLibraryWithPreLoadedPackageProfile(string frameworkName, string targetFrameworkName, int expectedScore)
        {
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=0.0"), 
                           new FrameworkName("MonoAndroid, Version=0.0"), 
                      });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();
            profileCollection.Add(profile1);

            NetPortableProfileTable.Profiles = profileCollection;

            // Arrange
            var framework = VersionUtility.ParseFrameworkName(frameworkName);
            var targetFramework = VersionUtility.ParseFrameworkName(targetFrameworkName);

            // Act
            int score = VersionUtility.GetCompatibilityBetweenPortableLibraryAndPortableLibrary(framework, targetFramework);

            // Assert
            Assert.Equal(expectedScore, score);
        }
コード例 #37
0
        internal static bool HasCompatibleProfileWith(NetPortableProfile packageFramework, FrameworkName projectOptionalFrameworkName)
        {
            List<VersionStringISetTuple> versionProfileISetTupleList = null;

            // In the dictionary _portableProfilesSetByOptionalFrameworks, 
            // key is the identifier of the optional framework and value is the tuple of (optional Framework Version, set of profiles in which they are optional)
            // We try to get a value with key as projectOptionalFrameworkName.Identifier. If one exists, we check if the project version is >= the version from the retrieved tuple
            // If so, then, we see if one of the profiles, in the set from the retrieved tuple, is compatible with the packageFramework profile
            if (_portableProfilesSetByOptionalFrameworks != null
                && _portableProfilesSetByOptionalFrameworks.TryGetValue(projectOptionalFrameworkName.Identifier, out versionProfileISetTupleList))
            {
                foreach (var versionProfileISetTuple in versionProfileISetTupleList)
                {
                    if (projectOptionalFrameworkName.Version >= versionProfileISetTuple.Item1)
                    {
                        foreach (var profileName in versionProfileISetTuple.Item2)
                        {
                            NetPortableProfile profile = GetProfile(profileName);
                            if (profile != null && packageFramework.IsCompatibleWith(profile))
                            {
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        }
コード例 #38
0
        public void TestParseWithStandardProfileString()
        {
            // Arrange & Act
            var profileCollection = new NetPortableProfileCollection();
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NetCore, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=3.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });
            profileCollection.Add(profile1);
            profileCollection.Add(profile2);

            NetPortableProfileTable.Profiles = profileCollection;

            var profile = NetPortableProfile.Parse("Profile2");

            // Assert
            Assert.Equal(3, profile.SupportedFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NetCore, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=3.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
        }
コード例 #39
0
        public void TestIsCompatibleWithPortableProfile11WithMonoProjectWithVersionLesserThanInstalledProfile()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.1"),
                           new FrameworkName("Windows, Version=8.0"),
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=1.0"), 
                           new FrameworkName("MonoAndroid, Version=2.0"),
                           new FrameworkName("MonoMac, Version=1.0"),
                      });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();
            profileCollection.Add(profile1);

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.0"),
                           new FrameworkName("Windows, Version=8.0"),
                      });

            var projectProfile = new FrameworkName("MonoAndroid, Version=1.0");

            NetPortableProfileTable.Profiles = profileCollection;

            // Act & Assert
            Assert.False(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #40
0
        public void TestIsCompatibleWithPortableProfile12WithMonoProjectWithMultipleInstalledProfileHavingMonoOfDifferentVersions()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.1"),
                           new FrameworkName("Windows, Version=8.0"),
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=1.0"), 
                           new FrameworkName("MonoAndroid, Version=3.0"),
                           new FrameworkName("MonoMac, Version=1.0"),
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.1"),
                           new FrameworkName("Windows, Version=8.0"),
                      },
               new[] { 
                           new FrameworkName("MonoAndroid, Version=1.0"),
                           new FrameworkName("MonoMac, Version=1.0"),
                      });

            var profile3 = new NetPortableProfile(
               "Profile3",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.5"),
                      },
               new[] { 
                           new FrameworkName("MonoAndroid, Version=3.0"),
                      });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();
            profileCollection.Add(profile1);
            profileCollection.Add(profile2);
            profileCollection.Add(profile3);

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName("Silverlight, Version=4.0"),
                           new FrameworkName("WindowsPhone, Version=7.0"),
                           new FrameworkName("Windows, Version=8.0"),
                      });

            var projectProfile = new FrameworkName("MonoAndroid, Version=2.0");

            NetPortableProfileTable.Profiles = profileCollection;

            // Act & Assert
            Assert.True(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #41
0
        public void TestParseWithCustomProfileString6WithOptionalFrameworkAndTreatedAsSupported()
        {
            // Arrange & Act
            var profileCollection = new NetPortableProfileCollection();
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=4.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      },
               new[] { 
                           new FrameworkName("MonoTouch, Version=0.0"), 
                           new FrameworkName("MonoAndroid, Version=2.0"), 
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NetCore, Version=4.5"), 
                           new FrameworkName("Silverlight, Version=3.0"), 
                           new FrameworkName("WindowsPhone, Version=7.1"), 
                      });
            profileCollection.Add(profile1);
            profileCollection.Add(profile2);

            NetPortableProfileTable.Profiles = profileCollection;

            var profile = NetPortableProfile.Parse("net45+sl40+wp71+MonoTouch+MonoAndroid20", treatOptionalFrameworksAsSupportedFrameworks: true);

            // Assert
            Assert.Equal(5, profile.SupportedFrameworks.Count);
            Assert.Equal(0, profile.OptionalFrameworks.Count);
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1")));
            Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0")));
        }
コード例 #42
0
        public void TestIsCompatibleWithPortableProfile12WithMonoProjectWithMultipleInstalledProfileHavingMonoOfDifferentVersions()
        {
            // Arrange
            var profile1 = new NetPortableProfile(
                "Profile1",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoTouch, Version=1.0"),
                new FrameworkName("MonoAndroid, Version=3.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            var profile2 = new NetPortableProfile(
                "Profile2",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.1"),
                new FrameworkName("Windows, Version=8.0"),
            },
                new[] {
                new FrameworkName("MonoAndroid, Version=1.0"),
                new FrameworkName("MonoMac, Version=1.0"),
            });

            var profile3 = new NetPortableProfile(
                "Profile3",
                new[] {
                new FrameworkName(".NETFramework, Version=4.5"),
                new FrameworkName("Silverlight, Version=4.5"),
            },
                new[] {
                new FrameworkName("MonoAndroid, Version=3.0"),
            });

            NetPortableProfileCollection profileCollection = new NetPortableProfileCollection();

            profileCollection.Add(profile1);
            profileCollection.Add(profile2);
            profileCollection.Add(profile3);

            var packageProfile = new NetPortableProfile(
                "ProfileXXX",
                new[] {
                new FrameworkName(".NETFramework, Version=4.0"),
                new FrameworkName("Silverlight, Version=4.0"),
                new FrameworkName("WindowsPhone, Version=7.0"),
                new FrameworkName("Windows, Version=8.0"),
            });

            var projectProfile = new FrameworkName("MonoAndroid, Version=2.0");

            NetPortableProfileTable.Profiles = profileCollection;

            // Act & Assert
            Assert.True(packageProfile.IsCompatibleWith(projectProfile));
        }
コード例 #43
0
        public void TestIsCompatibleWithPortableProfile5()
        {
            // Arrange 
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                      });

            var targetProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName(".NETCore, Version=4.0")
                      });

            // Act & Assert
            Assert.False(profile.IsCompatibleWith(targetProfile));
        }
コード例 #44
0
 string OrderProfileByName(NetPortableProfile profile)
 {
     string number = profile.Name.ToLowerInvariant().Replace("profile", "");
     return number.PadLeft(4, '0');
 }
コード例 #45
0
        public void TestIsCompatibleWithPortableProfile6()
        {
            // Arrange 
            var profile = new NetPortableProfile(
                "ProfileXXX",
                new[] { 
                           new FrameworkName("WindowsPhone, Version=8.0"), 
                      });

            var targetProfile = new NetPortableProfile(
                "MyProfile",
                new[] {
                           new FrameworkName("WindowsPhone, Version=8.0"), 
                      });

            // Act & Assert
            Assert.True(profile.IsCompatibleWith(targetProfile));
        }
コード例 #46
0
ファイル: Program.cs プロジェクト: emmanuelmathot/NuGet4Mono
        static Manifest InitiateManifestFromAssembly(Assembly assembly, IEnumerable<PackageReference> deps){
            Manifest manifest = new Manifest();

            AssemblyInfo ainfo = new AssemblyInfo(assembly);

            //Version
            manifest.Metadata.Version = ManifestVersionFromAssembly(ainfo);

            // Copyright
            manifest.Metadata.Copyright = ainfo.Copyright;

            // Authors
            if (ainfo.Authors != null) {
                manifest.Metadata.Authors = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
                manifest.Metadata.Owners = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
            }

            // Description
            manifest.Metadata.Description = ainfo.Description;

            // Icon Url
            if ( ainfo.IconUrl != null )
                manifest.Metadata.IconUrl = ainfo.IconUrl.ToString();

            // Id
            manifest.Metadata.Id = ainfo.ProductTitle;

            // License Url
            if (ainfo.LicenseUrl != null)
                manifest.Metadata.LicenseUrl = ainfo.LicenseUrl.ToString();

            // Project Url
            if (ainfo.ProjectUrl != null)
                manifest.Metadata.ProjectUrl = ainfo.ProjectUrl.ToString();

            // Tags
            manifest.Metadata.Tags = ainfo.Tags;

            // Title
            manifest.Metadata.Title = ainfo.ProductTitle;

            // Dependencies
            if (deps != null) {
                manifest.Metadata.DependencySets = new List<ManifestDependencySet>();

                foreach (var frameworkVersion in deps.Select<PackageReference, FrameworkName>(pr => pr.TargetFramework).Distinct().ToArray()) {

                    NetPortableProfile npp = new NetPortableProfile("test", new FrameworkName[1]{ frameworkVersion });

                    ManifestDependencySet mds = new ManifestDependencySet();
                    mds.Dependencies = new List<ManifestDependency>();
                    mds.TargetFramework = npp.CustomProfileString;

                    manifest.Metadata.DependencySets.Add(mds);
                    foreach (var dep in deps.Where(d => d.TargetFramework == frameworkVersion).ToArray()) {

                        ManifestDependency md = new ManifestDependency();
                        md.Id = dep.Id;
                        md.Version = dep.Version.ToNormalizedString();

                        mds.Dependencies.Add(md);


                    }
                }
            }

            return manifest;
        }
コード例 #47
0
ファイル: VersionUtilityTest.cs プロジェクト: rikoe/nuget
        public void TestGetShortNameForPortableXamarinFrameworks(string frameworkIdentifier, string expectedShortName)
        {
            // Arrange
            var profileCollection = new NetPortableProfileCollection();
            var profile1 = new NetPortableProfile(
               "Profile1",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.5"), 
                           new FrameworkName("Xamarin.Mac, Version=1.0"), 
                           new FrameworkName("Xamarin.iOS, Version=1.0"), 
                      });

            var profile2 = new NetPortableProfile(
               "Profile2",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName(".NetCore, Version=4.5"), 
                           new FrameworkName("Xamarin.PlayStation3, Version=1.0"), 
                           new FrameworkName("Xamarin.PlayStation4, Version=1.0"), 
                           new FrameworkName("Xamarin.PlayStationVita, Version=1.0"), 
                      });

            var profile3 = new NetPortableProfile(
               "Profile3",
               new[] { 
                           new FrameworkName(".NETFramework, Version=4.0"), 
                           new FrameworkName("Xamarin.Xbox360, Version=1.0"), 
                           new FrameworkName("Xamarin.XboxOne, Version=1.0"), 
                      });

            profileCollection.Add(profile1);
            profileCollection.Add(profile2);
            profileCollection.Add(profile3);

            var portableProfileTable = new NetPortableProfileTable(profileCollection);

            var framework = new FrameworkName(frameworkIdentifier);

            // Act
            string shortName = VersionUtility.GetShortFrameworkName(framework, portableProfileTable);

            // Assert
            Assert.Equal(expectedShortName, shortName);
        }
コード例 #48
0
ファイル: Program.cs プロジェクト: emmanuelmathot/NuGet4Mono
        static ManifestFile ManifestFileForAssembly(Assembly assembly, string path){
            ManifestFile mf = new ManifestFile();

            AssemblyInfo ainfo = new AssemblyInfo(assembly);

            mf.Source = path;

            string version = "";

            if (string.IsNullOrEmpty(ainfo.TargetFramework)) { 

                if (assembly.ImageRuntimeVersion.StartsWith("v2.0"))
                    version = "/net20";
                if (assembly.ImageRuntimeVersion.StartsWith("v3.5"))
                    version = "/net35";
                if (assembly.ImageRuntimeVersion.StartsWith("v4.0"))
                    version = "/net40";
                if (assembly.ImageRuntimeVersion.StartsWith("v4.5"))
                    version = "/net45";
            }
            else{

                NetPortableProfile npp = new NetPortableProfile("test", new FrameworkName[1]{new FrameworkName(ainfo.TargetFramework)});
                version = "/" + npp.CustomProfileString;
            }

            mf.Target = String.Format("lib{0}", version);

            return mf;
        }
コード例 #49
0
        static Manifest InitiateManifestFromAssembly(Assembly assembly, IEnumerable <PackageReference> deps)
        {
            Manifest manifest = new Manifest();

            AssemblyInfo ainfo = new AssemblyInfo(assembly);

            //Version
            manifest.Metadata.Version = ManifestVersionFromAssembly(ainfo);

            // Copyright
            manifest.Metadata.Copyright = ainfo.Copyright;

            // Authors
            if (ainfo.Authors != null)
            {
                manifest.Metadata.Authors = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
                manifest.Metadata.Owners  = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
            }

            // Description
            manifest.Metadata.Description = ainfo.Description;

            // Icon Url
            if (ainfo.IconUrl != null)
            {
                manifest.Metadata.IconUrl = ainfo.IconUrl.ToString();
            }

            // Id
            manifest.Metadata.Id = ainfo.ProductTitle;

            // License Url
            if (ainfo.LicenseUrl != null)
            {
                manifest.Metadata.LicenseUrl = ainfo.LicenseUrl.ToString();
            }

            // Project Url
            if (ainfo.ProjectUrl != null)
            {
                manifest.Metadata.ProjectUrl = ainfo.ProjectUrl.ToString();
            }

            // Tags
            manifest.Metadata.Tags = ainfo.Tags;

            // Title
            manifest.Metadata.Title = ainfo.ProductTitle;

            // Dependencies
            if (deps != null)
            {
                manifest.Metadata.DependencySets = new List <ManifestDependencySet>();

                NetPortableProfile npp = new NetPortableProfile(ainfo.TargetFramework, new FrameworkName[1] {
                    new FrameworkName(ainfo.TargetFramework)
                });

                ManifestDependencySet mds = new ManifestDependencySet();
                mds.Dependencies    = new List <ManifestDependency>();
                mds.TargetFramework = npp.CustomProfileString;

                manifest.Metadata.DependencySets.Add(mds);
                foreach (var dep in deps)
                {
                    ManifestDependency md = new ManifestDependency();
                    md.Id      = dep.Id;
                    md.Version = dep.Version.ToNormalizedString();

                    mds.Dependencies.Add(md);
                }
            }

            return(manifest);
        }
コード例 #50
0
 void WriteProfile(NetPortableProfile profile)
 {
     WriteLine("{0} {1}", profile.Name, profile.CustomProfileString);
 }