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)); }
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); }
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); }
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); }
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"))); }
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); }
private static FrameworkName GetFrameworkName(NetPortableProfile profile) { return(new FrameworkName( ".NETPortable", new Version(profile.FrameworkVersion.Substring(1)), // "v0.0" becomes "0.0" profile.Name)); }
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)); }
public void TestParseWithInvalidCustomProfileReturnsNull() { // Arrange & Act var profile = NetPortableProfile.Parse("Profile3284"); // Assert Assert.Null(profile); }
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); }
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))); }
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"))); }
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); }
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"))); }
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"))); }
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"))); }
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"))); }
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)); }
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"))); }
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); }
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)); }
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"))); }
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); }
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"))); }
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)); }
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); }
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); } }
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)); }
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)); }
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)); }
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; }
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); }
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); }
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; }
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)); }
string OrderProfileByName(NetPortableProfile profile) { string number = profile.Name.ToLowerInvariant().Replace("profile", ""); return number.PadLeft(4, '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)); }
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; }
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); }
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; }
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); }
void WriteProfile(NetPortableProfile profile) { WriteLine("{0} {1}", profile.Name, profile.CustomProfileString); }