public static CompatibilityResult GetCompatibilityResult()

in src/PortingAssistant.Client.Analysis/Utils/ApiCompatiblity.cs [59:115]


        public static CompatibilityResult GetCompatibilityResult(
            PackageDetailsWithApiIndices package, 
            string apiMethodSignature, 
            string packageVersion, 
            string target = "netcoreapp3.1", 
            bool checkLesserPackage = false)
        {
            var compatibilityResult = new CompatibilityResult
            {
                Compatibility = Compatibility.UNKNOWN,
                CompatibleVersions = new List<string>()
            };

            // If necessary data to determine compatibility is missing, return unknown compatibility
            if (package == null 
                || apiMethodSignature == null 
                || !NuGetVersion.TryParse(packageVersion, out var validPackageVersion))
            {
                return compatibilityResult;
            }

            if (package.PackageDetails.IsDeprecated)
            {
                compatibilityResult.Compatibility = Compatibility.DEPRECATED;
                return compatibilityResult;
            }

            var apiDetails = GetApiDetails(package, apiMethodSignature);
            var compatiblePackageVersionsForTarget = 
                GetCompatiblePackageVersionsForTarget(apiDetails, package, target, checkLesserPackage);

            // If package version is greater than the greatest compatible version, it is likely this latest version
            // has not been assessed and added to the compatibility datastore. If it has a lower version of the same
            // major that is compatible, then it will be marked as Compatible. It will be marked as Incompatible otherwise
            var maxCompatibleVersion = NugetVersionHelper.GetMaxVersion(compatiblePackageVersionsForTarget);
            if (maxCompatibleVersion != null 
                && !maxCompatibleVersion.IsZeroVersion()
                && validPackageVersion.IsGreaterThan(maxCompatibleVersion))
            {
                compatibilityResult.Compatibility = validPackageVersion.HasSameMajorAs(maxCompatibleVersion)
                    ? Compatibility.COMPATIBLE
                    : Compatibility.INCOMPATIBLE;
            }
            // In all other cases, just check to see if the list of compatible versions for the target framework
            // contains the current package version
            else
            {
                compatibilityResult.Compatibility = validPackageVersion.HasLowerOrEqualCompatibleVersion(compatiblePackageVersionsForTarget)
                    ? Compatibility.COMPATIBLE
                    : Compatibility.INCOMPATIBLE;
            }

            // CompatibleVersions are recommended as potential upgrades from current version
            compatibilityResult.CompatibleVersions = validPackageVersion.FindGreaterCompatibleVersions(compatiblePackageVersionsForTarget).ToList();

            return compatibilityResult;
        }