public void TestRuntimeBand()
        {
            var releases = JsonConvert.DeserializeObject <DotnetRelease[]>(Properties.Resources.DotnetReleasesJson);

            foreach (var release in releases)
            {
                if (release.RuntimeVersion == null)
                {
                    //Some releases do not contain a new runtime version.
                    continue;
                }

                var expected = SdkVersion.Parse(release.RuntimeVersion);
                var actual   = SdkVersion.Parse(release.SdkVersion).IncludedRuntimeBand;

                Assert.AreEqual(expected.Major, actual.Major);
                //V1 includes both 1.0 and 1.1 runtimes.
                if (expected.Major == 1)
                {
                    Assert.AreEqual(1, actual.Minor);
                }
                else
                {
                    Assert.AreEqual(expected.Minor, actual.Minor);
                }
                Assert.AreEqual(0, actual.Patch);
                Assert.IsTrue(string.IsNullOrEmpty(actual.PrereleaseLabel));
            }
        }
        public void TestEquals()
        {
            string[] distinctVersions = new string[]
            {
                "1.2.3",
                "4.5.6",
                "1.2.3-pre",
                "4.5.6-releasecanidate",
                "1.4.5",
                "1.2.4",
            };

            for (int i = 0; i < distinctVersions.Length; i++)
            {
                for (int j = i; j < distinctVersions.Length; j++)
                {
                    var  ver1  = SdkVersion.Parse(distinctVersions[i]);
                    var  ver2  = SdkVersion.Parse(distinctVersions[j]);
                    bool equal = ver1.Equals(ver2);
                    if (i == j)
                    {
                        Assert.IsTrue(equal, $"expected '{ver1}' to equal '{ver2}'");
                    }
                    else
                    {
                        Assert.IsFalse(equal, $"expected '{ver1}' to NOT equal '{ver2}'");
                    }
                }
            }
        }
        public void TestMultiBitPlan()
        {
            var delete = new DotNetCoreSdk[]
            {
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(1, 0, 1)),
                new DotNetCoreSdk(is64Bit: false, new SdkVersion(1, 0, 1)),
            };

            var keep = new DotNetCoreSdk[]
            {
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(1, 0, 4)),
                new DotNetCoreSdk(is64Bit: false, new SdkVersion(1, 0, 4)),
                new DotNetCoreSdk(is64Bit: false, new SdkVersion(1, 1, 4)),
            };

            var vsKeep = new DotNetCoreSdk[]
            {
            };

            var vsVersions = new SdkVersion[]
            {
            };

            TestPlan(delete, keep, vsKeep, keepOnlyLastVersionPerRuntime: false, vsVersions);
        }
Esempio n. 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (AppName.Length != 0)
            {
                hash ^= AppName.GetHashCode();
            }
            if (AppVersion.Length != 0)
            {
                hash ^= AppVersion.GetHashCode();
            }
            if (AppChannel.Length != 0)
            {
                hash ^= AppChannel.GetHashCode();
            }
            if (SdkVersion.Length != 0)
            {
                hash ^= SdkVersion.GetHashCode();
            }
            hash ^= ExtensionInfo.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 5
0
        private static void ParseVersionAndArch(string displayName, string bundleCachePath, out BundleVersion version, out BundleArch arch)
        {
            var match          = Regexes.BundleDisplayNameRegex.Match(displayName);
            var cachePathMatch = Regexes.BundleCachePathRegex.Match(bundleCachePath);
            var archString     = cachePathMatch.Groups[Regexes.ArchGroupName].Value ?? string.Empty;
            var versionString  = cachePathMatch.Groups[Regexes.VersionGroupName].Value;
            var hasAuxVersion  = cachePathMatch.Groups[Regexes.AuxVersionGroupName].Success;
            var footnote       = hasAuxVersion ?
                                 string.Format(LocalizableStrings.HostingBundleFootnoteFormat, displayName, versionString) :
                                 null;

            switch (match.Groups[Regexes.TypeGroupName].Value)
            {
            case "SDK": version = new SdkVersion(versionString); break;

            case "Runtime": version = new RuntimeVersion(versionString); break;

            case "ASP.NET": version = new AspNetRuntimeVersion(versionString); break;

            case "Windows Server Hosting": version = new HostingBundleVersion(versionString, footnote); break;

            default: throw new ArgumentException();
            }

            switch (archString)
            {
            case "x64": arch = BundleArch.X64; break;

            case "x86": arch = BundleArch.X86; break;

            case "": arch = BundleArch.X64 | BundleArch.X86; break;

            default: throw new ArgumentException();
            }
        }
Esempio n. 6
0
        internal void TestEquality(string input1, string input2)
        {
            var version1 = new SdkVersion(input1);
            var version2 = new SdkVersion(input2);

            TestUtils.EqualityComparisonTestUtils <SdkVersion> .TestEquality(version1, version2);
        }
Esempio n. 7
0
        public void TryParse_VersionIsEmptyString()
        {
            SdkVersion version = null;
            bool       result  = SdkVersion.TryParse(string.Empty, out version);

            Assert.IsFalse(result);
        }
Esempio n. 8
0
        public void ShouldToStringCorrectly()
        {
            const string Expected = "1.2.3";
            var          ver      = new SdkVersion(1, 2, 3);

            Assert.That(ver.ToString(), Is.EqualTo(Expected));
        }
Esempio n. 9
0
		/// <summary>
		/// Initializes a new instance of class MsdnXsltUtilities
		/// </summary>
		/// <param name="fileNames">A StringDictionary holding id to file name mappings.</param>
		/// <param name="elemNames">A StringDictionary holding id to element name mappings</param>
		/// <param name="linkToSdkDocVersion">Specifies the version of the SDK documentation.</param>
		/// <param name="linkToSdkDocLangauge">Specifies the version of the SDK documentation.</param>
		/// <param name="SdkLinksOnWeb">Specifies if links should be to ms online documentation.</param>
		/// <param name="fileEncoding">Specifies if links should be to ms online documentation.</param>
		public MsdnXsltUtilities(
			StringDictionary fileNames, 
			StringDictionary elemNames, 
			SdkVersion  linkToSdkDocVersion,
			string linkToSdkDocLangauge,
			bool SdkLinksOnWeb,
			System.Text.Encoding fileEncoding)
		{
			Reset();

			this.fileNames = fileNames;
			this.elemNames = elemNames;
			

			if (SdkLinksOnWeb)
			{
				sdkDocBaseUrl = msdnOnlineSdkBaseUrl;
				sdkDocExt = msdnOnlineSdkPageExt;
			}
			else
			{
				switch (linkToSdkDocVersion)
				{
					case SdkVersion.SDK_v1_0:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc10BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						break;
					case SdkVersion.SDK_v1_1:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc11BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						break;
				}
			}
			encodingString = "text/html; charset=" + fileEncoding.WebName; 
		}
Esempio n. 10
0
        public void TryParse_NullVersion()
        {
            SdkVersion version = null;
            bool       result  = SdkVersion.TryParse(null, out version);

            Assert.IsFalse(result);
        }
        public void TestWithPreRelease()
        {
            var delete = new DotNetCoreSdk[]
            {
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 2, 100, "-pre1")),
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 3, 100, "-pre1")),
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 3, 100)),
            };

            var keep = new DotNetCoreSdk[]
            {
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 2, 100)),
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 3, 101, "-pre1")),
                new DotNetCoreSdk(is64Bit: true, new SdkVersion(2, 4, 100, "-pre1")),
            };

            var vsKeep = new DotNetCoreSdk[]
            {
            };

            var vsVersions = new SdkVersion[]
            {
            };

            TestPlan(delete, keep, vsKeep, keepOnlyLastVersionPerRuntime: false, vsVersions);
        }
Esempio n. 12
0
        public void Equals_Version(string x, string y, bool expected)
        {
            var versionX = SdkVersion.Parse(x);
            var versionY = SdkVersion.Parse(y);

            Assert.AreEqual(expected, versionX.Equals(versionY));
        }
        private static FileStreamInfo VCLibsFromResources(TargetPlatform platform, DependencyConfiguration configuration, SdkVersion sdkVersion)
        {
            var vclibVersion = "";
            switch (sdkVersion)
            {
                case SdkVersion.SDK_10_0_10586_0: vclibVersion = "14.00"; break;
                default:
                    return null;
            }

            var platformString = "";
            switch (platform)
            {
                case TargetPlatform.X86: platformString = "x86"; break;
                case TargetPlatform.ARM: platformString = "ARM"; break;
                default:
                    return null;
            }

            var appxFilename = string.Format(CultureInfo.InvariantCulture, "Microsoft.VCLibs.{0}.{1}.{2}.appx", platformString, configuration.ToString(), vclibVersion);
            var assemblyName = typeof(CPlusPlusUwpDependency).Assembly.GetName().Name;
            var convertedPath = assemblyName + @".Resources.VCLibs." + platformString + "." + appxFilename;
            return new FileStreamInfo()
            {
                AppxRelativePath = appxFilename,
                Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(convertedPath)
            };
        }
Esempio n. 14
0
        internal void TestInequality(string lower, string higher)
        {
            var lowerVersion  = new SdkVersion(lower);
            var higherVersion = new SdkVersion(higher);

            TestUtils.EqualityComparisonTestUtils <SdkVersion> .TestInequality(lowerVersion, higherVersion);
        }
Esempio n. 15
0
        /// <summary>
        /// Attempts to extract the SDK version from the registry.
        /// </summary>
        /// <param name="ver">The SDK version will be saved in this variable.</param>
        /// <returns>
        /// <c>true</c> if the version was retrieved successfully and stored in <paramref name="ver" />,
        /// otherwise <c>false</c> with <c>(0, 0, 0)</c> stored in <paramref name="ver" />.
        /// </returns>
        internal static bool TryGetSdkVersion(out SdkVersion ver)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Log.Debug("Not running on Windows platform, aborting registry check");
                ver = new SdkVersion(0, 0, 0);
                return(false);
            }

            try
            {
                using (var key = Registry.LocalMachine.OpenSubKey(SdkRegKeyPath, false))
                {
                    if (key == null)
                    {
                        Log.Warn("Failed to open registry key to read SDK version.");
                        ver = new SdkVersion(0, 0, 0);
                        return(false);
                    }

                    var major    = key.GetValue("MajorVersion");
                    var minor    = key.GetValue("MinorVersion");
                    var revision = key.GetValue("RevisionNumber");

                    if (major is int majorInt && minor is int minorInt && revision is int revInt)
                    {
                        ver = new SdkVersion(majorInt, minorInt, revInt);
                        return(true);
                    }

                    Log.WarnFormat(
                        "Unknown version component types, please tell a developer: Ma is {0}, Mi is {1}, R is {2}.",
                        major?.GetType().ToString() ?? "<NULL>",
                        minor?.GetType().ToString() ?? "<NULL>",
                        revision?.GetType().ToString() ?? "<NULL>");

                    ver = new SdkVersion(0, 0, 0);
                    return(false);
                }
            }
            catch (PlatformNotSupportedException ex)
            {
                Log.WarnException("Can't obtain SDK version due to registry not being supported on this system", ex);
                ver = new SdkVersion(0, 0, 0);
                return(false);
            }
            catch (SecurityException ex)
            {
                Log.WarnException("System raised SecurityException during read of SDK version in registry.", ex);
                ver = new SdkVersion(0, 0, 0);
                return(false);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.WarnException("Not authorized to read registry for SDK version.", ex);
                ver = new SdkVersion(0, 0, 0);
                return(false);
            }
        }
Esempio n. 16
0
        public void ShouldConstructWithCorrectValues()
        {
            var ver = new SdkVersion(1, 2, 3);

            Assert.That(ver.Major, Is.EqualTo(1));
            Assert.That(ver.Minor, Is.EqualTo(2));
            Assert.That(ver.Revision, Is.EqualTo(3));
        }
Esempio n. 17
0
        public void AddPackage_DoesNotExcludeCurrentOne()
        {
            var sut = new SdkVersion();

            sut.AddPackage("Sentry", "1.0");
            sut.AddPackage("Sentry.Log4Net", "10.0");

            Assert.Equal(2, sut.Packages.Count());
        }
Esempio n. 18
0
        public void ShouldThrowExceptionWhenComparingDifferentObjects()
        {
            var ver = new SdkVersion(1, 2, 3);
            var obj = new object();

            Assert.That(
                () => ver.CompareTo(obj),
                Throws.InstanceOf <ArgumentException>().With.Property("ParamName").EqualTo("obj"));
        }
        public void AddIntegration_DoesNotExcludeCurrentOne()
        {
            var sut = new SdkVersion();

            sut.AddIntegration("integration 1");
            sut.AddIntegration("integration 2");

            Assert.Equal(2, sut.Integrations.Count());
        }
Esempio n. 20
0
		/// <summary>
		/// Initializes a new instance of class MsdnXsltUtilities
		/// </summary>
		/// <param name="fileNames">A StringDictionary holding id to file name mappings.</param>
		/// <param name="elemNames">A StringDictionary holding id to element name mappings</param>
		/// <param name="linkToSdkDocVersion">Specifies the version of the SDK documentation.</param>
		/// <param name="linkToSdkDocLangauge">Specifies the version of the SDK documentation.</param>
		/// <param name="SdkLinksOnWeb">Specifies if links should be to ms online documentation.</param>
		/// <param name="fileEncoding">Specifies if links should be to ms online documentation.</param>
		public MsdnXsltUtilities(
			StringDictionary fileNames, 
			StringDictionary elemNames, 
			SdkVersion  linkToSdkDocVersion,
			string linkToSdkDocLangauge,
			bool SdkLinksOnWeb,
			System.Text.Encoding fileEncoding)
		{
			Reset();

			this.fileNames = fileNames;
			this.elemNames = elemNames;
			

			if (SdkLinksOnWeb)
			{
				sdkDocBaseUrl = msdnOnlineSdkBaseUrl;
				sdkDocExt = msdnOnlineSdkPageExt;
			}
			else
			{
				switch (linkToSdkDocVersion)
				{
					case SdkVersion.SDK_v1_0:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc10BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						frameworkVersion="1.0";
                        sdkVersion = SdkVersion.SDK_v1_0;
                        break;
					case SdkVersion.SDK_v1_1:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc11BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						frameworkVersion="1.1";
                        sdkVersion = SdkVersion.SDK_v1_1;
                        break;
                    case SdkVersion.SDK_v2_0:
                        sdkRoot = "/cpref2/html/";
                        sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc20BaseNamespace, linkToSdkDocLangauge);
                        sdkDocExt = sdkDocPageExt;
                        frameworkVersion = "2.0";
                        sdkVersion = SdkVersion.SDK_v2_0;
                        break;
					default:
						Debug.Assert( false );		// remind ourselves to update this list when new framework versions are supported
						break;
				}
            }
			encodingString = "text/html; charset=" + fileEncoding.WebName;

            // System reflection incorrectly reports Enumerator, KeyCollection and ValueCollection base types, so fix it here!
            map = new Dictionary<string, string>();
            map.Add("System.Collections.Generic.Enumerator`1", "System.Collections.Generic.IEnumerator`1");
            map.Add("System.Collections.Generic.Enumerator`2", "System.Collections.Generic.IEnumerator`1");
            map.Add("System.Collections.Generic.KeyCollection`2", "System.Collections.Generic.Dictionary`2_KeyCollection");
            map.Add("System.Collections.Generic.ValueCollection`2", "System.Collections.Generic.Dictionary`2_ValueCollection");
        }
 public ReadOnlyCollection<FileStreamInfo> GetDependencies(TargetPlatform platform, DependencyConfiguration configuration, SdkVersion sdkVersion)
 {
     var dependencies = new List<FileStreamInfo>();
     var dependency = VCLibsFromResources(platform, configuration, sdkVersion);
     if (null != dependency)
     {
         dependencies.Add(dependency);
     }
     return new ReadOnlyCollection<FileStreamInfo>(dependencies);
 }
Esempio n. 22
0
        public void CompareTo_StableVersion()
        {
            var versionX = SdkVersion.Parse("1.0.2");
            var versionY = SdkVersion.Parse("1.2.3");

            Assert.IsTrue(versionX.CompareTo(versionX) == 0);
            Assert.IsTrue(versionY.CompareTo(versionY) == 0);
            Assert.IsTrue(versionX.CompareTo(versionY) < 0);
            Assert.IsTrue(versionY.CompareTo(versionX) > 0);
        }
Esempio n. 23
0
        public void CompareTo_PrereleaseVersions()
        {
            var versionX = SdkVersion.Parse("1.0.2");
            var versionY = SdkVersion.Parse("1.0.2-preview1-002912-00");

            Assert.IsTrue(versionX.CompareTo(versionX) == 0);
            Assert.IsTrue(versionY.CompareTo(versionY) == 0);
            Assert.IsTrue(versionX.CompareTo(versionY) > 0);
            Assert.IsTrue(versionY.CompareTo(versionX) < 0);
        }
Esempio n. 24
0
        public void ShouldNotEqualArbitraryObject()
        {
            var ver = new SdkVersion(1, 2, 3);
            var obj = new object();

            Assert.AreNotEqual(ver, obj);
            Assert.False(ver == obj);
            Assert.True(ver != obj);
            Assert.False(ver.Equals(obj));
        }
Esempio n. 25
0
        public void ShouldNotEqualDifferentVersion()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(3, 2, 1);

            Assert.AreNotEqual(a, b);
            Assert.False(a == b);
            Assert.True(a != b);
            Assert.False(a.Equals(b));
        }
Esempio n. 26
0
        public void ShouldEqualIdenticalVersion()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(1, 2, 3);

            Assert.AreEqual(a, b);
            Assert.True(a == b);
            Assert.False(a != b);
            Assert.True(a.Equals(b));
        }
Esempio n. 27
0
        private static void UpdatePackageReferences(NewProjectSettings settings)
        {
            try
            {
                string productVersion = Assembly.GetEntryAssembly().GetProductVersion();
                string flutterVersion = settings.FlutterVersion;
                if (string.IsNullOrEmpty(flutterVersion))
                {
                    flutterVersion = FlutterTools.GetVersion().Version;
                }

                SdkVersion        sdk = AppSettings.Default.SdkTable.Versions.First(v => v.Version == productVersion);
                SdkFlutterVersion fv  = sdk.Compatibility.FirstOrDefault(f => VersionUtils.Compare(f.Version, flutterVersion) == 0);
                if (fv == null)
                {
                    // We're using a version of Flutter that is not officially supported by Flutnet (no binding libraries exist).
                    // Let's try and see if we can find a prior version that's fully compatible.
                    // If we can't find anything, simply return and keep the template configuration as is.
                    sdk.Compatibility.Sort(new SdkFlutterVersionComparer());
                    fv = sdk.Compatibility.LastOrDefault(f => VersionUtils.Compare(f.Version, flutterVersion) < 0);
                    if (fv == null)
                    {
                        return;
                    }
                }

                if (settings.TargetAndroid)
                {
                    string interopVersion = !string.IsNullOrEmpty(fv.AndroidInteropVersion)
                        ? fv.AndroidInteropVersion
                        : fv.Version;

                    string csprojPath = Path.Combine(settings.SolutionPath, $"{settings.ProjectName}.Android", $"{settings.ProjectName}.Android.csproj");
                    UpdatePackageReferences_AndroidProject(csprojPath, interopVersion);
                    csprojPath = Path.Combine(settings.SolutionPath, $"{settings.ProjectName}.ModuleInterop.Android", $"{settings.ProjectName}.ModuleInterop.Android.csproj");
                    UpdatePackageReferences_AndroidProject(csprojPath, interopVersion);
                }

                if (settings.TargetIos && OperatingSystem.IsMacOS())
                {
                    string interopVersion = !string.IsNullOrEmpty(fv.IosInteropVersion)
                        ? fv.IosInteropVersion
                        : fv.Version;

                    string csprojPath = Path.Combine(settings.SolutionPath, $"{settings.ProjectName}.iOS", $"{settings.ProjectName}.iOS.csproj");
                    UpdatePackageReferences_iOSProject(csprojPath, interopVersion);
                    csprojPath = Path.Combine(settings.SolutionPath, $"{settings.ProjectName}.PluginInterop.iOS", $"{settings.ProjectName}.PluginInterop.iOS.csproj");
                    UpdatePackageReferences_iOSProject(csprojPath, interopVersion);
                }
            }
            catch (Exception e)
            {
                throw new CommandLineException(CommandLineErrorCode.NewProject_SetNativeReferencesFailed, e);
            }
        }
Esempio n. 28
0
        public void AddIntegrations_DoesNotExcludeCurrentOne()
        {
            var sut = new SdkVersion
            {
                InternalIntegrations = ImmutableList.Create("integration 1")
            };

            sut.AddIntegrations(new[] { "integration 2", "integration 3" });

            Assert.Equal(3, sut.Integrations.Count);
        }
Esempio n. 29
0
        public void Parse_StableVersion()
        {
            var version = SdkVersion.Parse("1.2.3");

            Assert.AreEqual(1, version.Major);
            Assert.AreEqual(2, version.Minor);
            Assert.AreEqual(3, version.Patch);
            Assert.AreEqual("1.2.3", version.Version.ToString());
            Assert.IsFalse(version.IsPrerelease);
            Assert.AreEqual("1.2.3", version.ToString());
        }
Esempio n. 30
0
    public static bool IsSdkDllActive(SdkVersion version)
    {
        string         assembly = version.ToString();
        PluginImporter importer = AssetImporter.GetAtPath("Assets/VRCSDK/Plugins/" + assembly + ".dll") as PluginImporter;

        if (importer == false)
        {
            return(false);
        }
        return(importer.GetCompatibleWithAnyPlatform());
    }
Esempio n. 31
0
        public void ShouldBeLessOrGreaterOrEqualWhenIdentical()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(1, 2, 3);

            Assert.That(a, Is.LessThanOrEqualTo(b));
            Assert.That(a, Is.GreaterThanOrEqualTo(b));
            Assert.True(a <= b);
            Assert.True(a >= b);
            Assert.False(a > b);
            Assert.False(a < b);
        }
Esempio n. 32
0
        public void ShouldBeGreaterThanWhenRevisionGreater()
        {
            var @new = new SdkVersion(1, 2, 3);
            var old = new SdkVersion(1, 2, 2);

            Assert.That(@new, Is.GreaterThan(old));
            Assert.That(@new, Is.GreaterThanOrEqualTo(old));
            Assert.True(@new > old);
            Assert.True(@new >= old);
            Assert.False(@new < old);
            Assert.False(@new <= old);
        }
Esempio n. 33
0
        public void ShouldBeLessThanWhenMajorLess()
        {
            var old  = new SdkVersion(1, 2, 3);
            var @new = new SdkVersion(2, 2, 3);

            Assert.That(old, Is.LessThan(@new));
            Assert.That(old, Is.LessThanOrEqualTo(@new));
            Assert.True(old < @new);
            Assert.True(old <= @new);
            Assert.False(old > @new);
            Assert.False(old >= @new);
        }
Esempio n. 34
0
        public void ShouldBeLessOrGreaterOrEqualWhenIdentical()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(1, 2, 3);

            Assert.That(a, Is.LessThanOrEqualTo(b));
            Assert.That(a, Is.GreaterThanOrEqualTo(b));
            Assert.True(a <= b);
            Assert.True(a >= b);
            Assert.False(a > b);
            Assert.False(a < b);
        }
Esempio n. 35
0
        public void ShouldBeGreaterThanWhenRevisionGreater()
        {
            var @new = new SdkVersion(1, 2, 3);
            var old  = new SdkVersion(1, 2, 2);

            Assert.That(@new, Is.GreaterThan(old));
            Assert.That(@new, Is.GreaterThanOrEqualTo(old));
            Assert.True(@new > old);
            Assert.True(@new >= old);
            Assert.False(@new < old);
            Assert.False(@new <= old);
        }
Esempio n. 36
0
        // Attempts to read the SDK version file from the SDK path and extracts the version.
        // If the read or parsing failed, logs an error and returns null.
        public static SdkVersion GetSdkVersion()
        {
            string fullVersion = GetFullSdkVersionString();

            if (string.IsNullOrEmpty(fullVersion))
            {
                return(null);
            }

            string version = fullVersion.Split().First();

            return(SdkVersion.Create(version));
        }
Esempio n. 37
0
		/// <summary>
		/// Initializes a new instance of class MsdnXsltUtilities
		/// </summary>
		/// <param name="fileNames">A StringDictionary holding id to file name mappings.</param>
		/// <param name="elemNames">A StringDictionary holding id to element name mappings</param>
		/// <param name="linkToSdkDocVersion">Specifies the version of the SDK documentation.</param>
		/// <param name="linkToSdkDocLangauge">Specifies the version of the SDK documentation.</param>
		/// <param name="SdkLinksOnWeb">Specifies if links should be to ms online documentation.</param>
		/// <param name="fileEncoding">Specifies if links should be to ms online documentation.</param>
		public MsdnXsltUtilities(
			StringDictionary fileNames, 
			StringDictionary elemNames, 
			SdkVersion  linkToSdkDocVersion,
			string linkToSdkDocLangauge,
			bool SdkLinksOnWeb,
			System.Text.Encoding fileEncoding)
		{
			Reset();

			this.fileNames = fileNames;
			this.elemNames = elemNames;
			

			if (SdkLinksOnWeb)
			{
				sdkDocBaseUrl = msdnOnlineSdkBaseUrl;
				sdkDocExt = msdnOnlineSdkPageExt;
			}
			else
			{
				switch (linkToSdkDocVersion)
				{
					case SdkVersion.SDK_v1_0:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc10BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						frameworkVersion="1.0";
						break;
					case SdkVersion.SDK_v1_1:
						sdkDocBaseUrl = GetLocalizedFrameworkURL(sdkDoc11BaseNamespace,linkToSdkDocLangauge);
						sdkDocExt = sdkDocPageExt;
						frameworkVersion="1.1";
						break;
					default:
						Debug.Assert( false );		// remind ourselves to update this list when new framework versions are supported
						break;
				}
			}
			encodingString = "text/html; charset=" + fileEncoding.WebName; 
		}
Esempio n. 38
0
        public void ShouldThrowExceptionWhenComparingDifferentObjects()
        {
            var ver = new SdkVersion(1, 2, 3);
            var obj = new object();

            Assert.That(
                () => ver.CompareTo(obj),
                Throws.InstanceOf<ArgumentException>().With.Property("ParamName").EqualTo("obj"));
        }
Esempio n. 39
0
        /// <summary>
        /// Attempts to extract the SDK version from the registry.
        /// </summary>
        /// <param name="ver">The SDK version will be saved in this variable.</param>
        /// <returns>
        /// <c>true</c> if the version was retrieved successfully and stored in <paramref name="ver" />,
        /// otherwise <c>false</c> with <c>(0, 0, 0)</c> stored in <paramref name="ver" />.
        /// </returns>
        internal static bool TryGetSdkVersion(out SdkVersion ver)
        {
            try
            {
                using (var key = Registry.LocalMachine.OpenSubKey(SdkRegKeyPath, false))
                {
                    if (key == null)
                    {
                        Log.Warn("Failed to open registry key to read SDK version.");
                        ver = new SdkVersion(0, 0, 0);
                        return false;
                    }

                    var major = key.GetValue("MajorVersion");
                    var minor = key.GetValue("MinorVersion");
                    var revision = key.GetValue("RevisionNumber");

                    if (major is int && minor is int && revision is int)
                    {
                        ver = new SdkVersion((int)major, (int)minor, (int)revision);
                        return true;
                    }

                    Log.WarnFormat(
                        "Unknown version component types, please tell a developer: Ma is {0}, Mi is {1}, R is {2}.",
                        major.GetType(),
                        minor.GetType(),
                        revision.GetType());

                    ver = new SdkVersion(0, 0, 0);
                    return false;
                }
            }
            catch (SecurityException ex)
            {
                Log.Warn("System raised SecurityException during read of SDK version in registry.", ex);
                ver = new SdkVersion(0, 0, 0);
                return false;
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Warn("Not authorized to read registry for SDK version.", ex);
                ver = new SdkVersion(0, 0, 0);
                return false;
            }
        }
Esempio n. 40
0
		public static void Reset (bool full)
		{
			if (!full)
				return;
			
			Checked = false;
			Unsafe = false;
			StdLib = true;
			StrongNameKeyFile = null;
			StrongNameKeyContainer = null;
			StrongNameDelaySign = false;
			MainClass = null;
			OutputFile = null;
			Target = Target.Exe;
			SdkVersion = SdkVersion.v2;
			TargetExt = ".exe";
			Platform = Platform.AnyCPU;
			Version = LanguageVersion.Default;
			VerifyClsCompliance = true;
			Optimize = true;
			Encoding = Encoding.Default;
			Documentation = null;
			GenerateDebugInfo = false;
			ParseOnly = false;
			TokenizeOnly = false;
			Win32IconFile = null;
			Win32ResourceFile = null;
			Resources = null;
			LoadDefaultReferences = true;
			AssemblyReferences = new List<string> ();
			AssemblyReferencesAliases = new List<Tuple<string, string>> ();
			Modules = new List<string> ();
			ReferencesLookupPaths = new List<string> ();
			StdLibRuntimeVersion = RuntimeVersion.v2;

			//
			// Setup default defines
			//
			AllDefines = new List<string> ();
			AddConditional ("__MonoCS__");
		}
Esempio n. 41
0
        public void ShouldConstructWithCorrectValues()
        {
            var ver = new SdkVersion(1, 2, 3);

            Assert.That(ver.Major, Is.EqualTo(1));
            Assert.That(ver.Minor, Is.EqualTo(2));
            Assert.That(ver.Revision, Is.EqualTo(3));
        }
Esempio n. 42
0
        public void ShouldEqualIdenticalVersion()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(1, 2, 3);

            Assert.AreEqual(a, b);
            Assert.True(a == b);
            Assert.False(a != b);
            Assert.True(a.Equals(b));
        }
Esempio n. 43
0
        public void ShouldNotEqualDifferentVersion()
        {
            var a = new SdkVersion(1, 2, 3);
            var b = new SdkVersion(3, 2, 1);

            Assert.AreNotEqual(a, b);
            Assert.False(a == b);
            Assert.True(a != b);
            Assert.False(a.Equals(b));
        }
Esempio n. 44
0
        public void ShouldBeLessThanWhenMajorLess()
        {
            var old = new SdkVersion(1, 2, 3);
            var @new = new SdkVersion(2, 2, 3);

            Assert.That(old, Is.LessThan(@new));
            Assert.That(old, Is.LessThanOrEqualTo(@new));
            Assert.True(old < @new);
            Assert.True(old <= @new);
            Assert.False(old > @new);
            Assert.False(old >= @new);
        }
Esempio n. 45
0
        private void HandleSdkVersionFromCommandLine(string value)
        {
            sdk = GetSdkVersionFromString(value);
            if (sdk != SdkVersion.Unknown)
            {
                return;
            }

            var sb = new StringBuilder();
            var sdkVersionMembers = typeof(SdkVersion).GetEnumValues();
            for (var i = 0; i < sdkVersionMembers.Length; i++)
            {
                var sdkVersionMember = (SdkVersion)sdkVersionMembers.GetValue(i);
                if (SdkVersion.Unknown == sdkVersionMember) continue;

                var field = typeof(SdkVersion).GetField(sdkVersionMember.ToString());
                var customAttributes = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
                for (var j = 0; j < customAttributes.Length; j++)
                {
                    var descriptionAttribute = customAttributes[j] as DescriptionAttribute;
                    if (descriptionAttribute != null)
                    {
                        if (sb.Length != 0) sb.Append(", ");
                        sb.Append(descriptionAttribute.Description);
                    }
                }
            }

            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resource.DeploymentWorker_SupportedSdksErrorMsg, sb.ToString()));
        }
Esempio n. 46
0
        public void ShouldNotEqualArbitraryObject()
        {
            var ver = new SdkVersion(1, 2, 3);
            var obj = new object();

            Assert.AreNotEqual(ver, obj);
            Assert.False(ver == obj);
            Assert.True(ver != obj);
            Assert.False(ver.Equals(obj));
        }
Esempio n. 47
0
 public void ShouldToStringCorrectly()
 {
     const string Expected = "1.2.3";
     var ver = new SdkVersion(1, 2, 3);
     Assert.That(ver.ToString(), Is.EqualTo(Expected));
 }