private static string[] GetSorted(
     FindBestVersionMatchOutput output,
     Func <VersionCompatibility, bool> predicate = null)
 {
     return(output
            .Result
            .Versions
            .Where(predicate ?? (v => true))
            .OrderBy(x => x.Version)
            .Select(x => x.Version.ToNormalizedString())
            .ToArray());
 }
        public FindBestVersionMatchOutput FindBestVersionMatch(FindBestVersionMatchInput input)
        {
            var output = new FindBestVersionMatchOutput
            {
                InputStatus = InputStatus.Missing,
                Input       = input,
            };

            if (input == null)
            {
                return(output);
            }

            var validatedVersionRange = InputValidator.VersionRange(input.VersionRange);
            var validatedVersions     = InputValidator.Versions(input.Versions);

            if (validatedVersionRange.IsMissing || validatedVersions.IsMissing)
            {
                return(output);
            }

            if (validatedVersionRange.IsInvalid || validatedVersions.IsInvalid)
            {
                output.InputStatus = InputStatus.Invalid;
                return(output);
            }

            output.InputStatus = InputStatus.Valid;
            output.Result      = GetBestVersionMatch(
                validatedVersionRange.Data,
                validatedVersions.Data,
                listed: null,
                showUnlisted: true);

            return(output);
        }