Esempio n. 1
0
		private PackageCompatibility GetIndividualForwardCompatibility(PackageInfo package, PackageInfo target)
		{
			if (package.Id == target.Id) return PackageCompatibility.Definite;

			PackageNamePair key = new PackageNamePair { First = package.PackageName, Second = target.PackageName };
			PackageCompatibility compatibility;
			lock (this.cacheLock)
			{
				if (this.forwardCompatibilityCache.TryGetValue(key, out compatibility))
					return compatibility;
			}

			compatibility = PackageCompatibility.Definite;

			// Evaluate how the package depends on the target.
			PackageName dependecy = package.Dependencies.FirstOrDefault(d => d.Id == target.Id);
			if (!string.IsNullOrWhiteSpace(dependecy.Id))
			{
				PackageInfo dependencyInfo = this.QueryPackageInfo(dependecy);
				if (dependencyInfo == null)
				{
					// If no information is available on this dependency, don't assume compatibility
					compatibility = PackageCompatibility.None;
				}
				else if (!dependencyInfo.IsDualityPackage)
				{
					// If it is not a Duality package, ignore this
					compatibility = PackageCompatibility.Definite;
				}
				else if (dependecy.Version >= target.Version)
				{
					// If the package depends on a newer or similar version, it's okay
					compatibility = PackageCompatibility.Definite;
				}
				else if (dependecy.Version.Major == target.Version.Major && dependecy.Version.Minor == target.Version.Minor)
				{
					// If the target is equal in major and minor, it should be okay
					compatibility = PackageCompatibility.Likely;
				}
				else if (dependencyInfo.PublishDate > target.PublishDate)
				{
					// If the package depends on something that was released after the target, it should be okay
					compatibility = PackageCompatibility.Likely;
				}
				else if (dependecy.Version.Major == target.Version.Major)
				{
					// If the target is equal in major, it could be okay but doesn't have to be
					compatibility = PackageCompatibility.Unlikely;
				}
				else 
				{
					// Otherwise, no compatibility can be assumed
					compatibility = PackageCompatibility.None;
				}
			}
			
			lock (this.cacheLock)
			{
				this.forwardCompatibilityCache[key] = compatibility;
			}
			return compatibility;
		}
Esempio n. 2
0
        private PackageCompatibility GetIndividualForwardCompatibility(PackageInfo package, PackageInfo target)
        {
            if (package.Id == target.Id)
            {
                return(PackageCompatibility.Definite);
            }

            PackageNamePair key = new PackageNamePair {
                First = package.PackageName, Second = target.PackageName
            };
            PackageCompatibility compatibility;

            lock (this.cacheLock)
            {
                if (this.forwardCompatibilityCache.TryGetValue(key, out compatibility))
                {
                    return(compatibility);
                }
            }

            compatibility = PackageCompatibility.Definite;

            // Evaluate how the package depends on the target.
            PackageName dependecy = package.Dependencies.FirstOrDefault(d => d.Id == target.Id);

            if (!string.IsNullOrWhiteSpace(dependecy.Id))
            {
                PackageInfo dependencyInfo = this.QueryPackageInfo(dependecy);
                if (dependencyInfo == null)
                {
                    // If no information is available on this dependency, don't assume compatibility
                    compatibility = PackageCompatibility.None;
                }
                else if (!dependencyInfo.IsDualityPackage)
                {
                    // If it is not a Duality package, ignore this
                    compatibility = PackageCompatibility.Definite;
                }
                else if (dependecy.Version >= target.Version)
                {
                    // If the package depends on a newer or similar version, it's okay
                    compatibility = PackageCompatibility.Definite;
                }
                else if (dependecy.Version.Major == target.Version.Major && dependecy.Version.Minor == target.Version.Minor)
                {
                    // If the target is equal in major and minor, it should be okay
                    compatibility = PackageCompatibility.Likely;
                }
                else if (dependencyInfo.PublishDate > target.PublishDate)
                {
                    // If the package depends on something that was released after the target, it should be okay
                    compatibility = PackageCompatibility.Likely;
                }
                else if (dependecy.Version.Major == target.Version.Major)
                {
                    // If the target is equal in major, it could be okay but doesn't have to be
                    compatibility = PackageCompatibility.Unlikely;
                }
                else
                {
                    // Otherwise, no compatibility can be assumed
                    compatibility = PackageCompatibility.None;
                }
            }

            lock (this.cacheLock)
            {
                this.forwardCompatibilityCache[key] = compatibility;
            }
            return(compatibility);
        }