public static ApiRecommendation UpgradeStrategy( CompatibilityResult compatibilityResult, string apiMethodSignature, string nameSpaceToQuery, Task <RecommendationDetails> recommendationDetails) { try { if (compatibilityResult != null && compatibilityResult.CompatibleVersions != null) { var validVersions = compatibilityResult.CompatibleVersions.Where(v => !v.Contains("-")).ToList(); if (validVersions.Count != 0) { return(new ApiRecommendation { RecommendedActionType = RecommendedActionType.UpgradePackage, Description = validVersions.FirstOrDefault() }); } } return(FetchApiRecommendation(apiMethodSignature, nameSpaceToQuery, recommendationDetails)); } catch { return(DEFAULT_RECOMMENDATION); } }
private void ClearFields() { _Command = String.Empty; _Parameters = String.Empty; _Result = CompatibilityResult.Close; _PersistResponse = false; }
public static CompatibilityResult GetCompatibilityResult(PackageDetailsWithApiIndices package, string apiMethodSignature, string version, string target = DEFAULT_TARGET, bool checkLesserPackage = false) { var compatiblityResult = new CompatibilityResult { Compatibility = Compatibility.UNKNOWN, CompatibleVersions = new List <string>() }; if (package == null || apiMethodSignature == null || !NuGetVersion.TryParse(version, out var targetversion)) { return(compatiblityResult); } if (package.PackageDetails.IsDeprecated) { compatiblityResult.Compatibility = Compatibility.DEPRECATED; return(compatiblityResult); } var foundApi = GetApiDetails(package, apiMethodSignature); if (foundApi == null) { if (!checkLesserPackage || package.PackageDetails.Targets == null || !package.PackageDetails.Targets.TryGetValue(target, out var targetFramework)) { compatiblityResult.Compatibility = Compatibility.INCOMPATIBLE; return(compatiblityResult); } compatiblityResult.Compatibility = hasLesserTarget(version, targetFramework.ToArray()) ? Compatibility.COMPATIBLE : Compatibility.INCOMPATIBLE; compatiblityResult.CompatibleVersions = targetFramework.ToArray() .Where(v => { if (!NuGetVersion.TryParse(v, out var semversion)) { return(false); } return(semversion.CompareTo(targetversion) > 0); }).ToList(); return(compatiblityResult); } if (!foundApi.Targets.TryGetValue(target, out var framework)) { compatiblityResult.Compatibility = Compatibility.INCOMPATIBLE; return(compatiblityResult); } compatiblityResult.Compatibility = hasLesserTarget(version, framework.ToArray()) ? Compatibility.COMPATIBLE : Compatibility.INCOMPATIBLE; compatiblityResult.CompatibleVersions = framework.ToArray() .Where(v => { if (!NuGetVersion.TryParse(v, out var semversion)) { return(false); } return(semversion.CompareTo(targetversion) > 0); }).ToList(); return(compatiblityResult); }
public static ApiRecommendation UpgradeStrategy( CompatibilityResult compatibilityResult, string apiMethodSignature, Task <RecommendationDetails> recommendationDetails, string target = "netcoreapp3.1") { try { if (compatibilityResult?.CompatibleVersions != null) { var validVersions = compatibilityResult.GetCompatibleVersionsWithoutPreReleases(); if (validVersions.Count != 0) { return(new ApiRecommendation { RecommendedActionType = RecommendedActionType.UpgradePackage, Description = validVersions.FirstOrDefault() }); } } return(FetchApiRecommendation(apiMethodSignature, recommendationDetails, target)); } catch { return(DEFAULT_RECOMMENDATION); } }
private bool AnnotationsAreCompatible( PrimitivePropertyConfiguration other, ref string errorMessage) { bool flag = true; foreach (KeyValuePair <string, object> annotation1 in (IEnumerable <KeyValuePair <string, object> >) this.Annotations) { if (other.Annotations.ContainsKey(annotation1.Key)) { object objA = annotation1.Value; object annotation2 = other.Annotations[annotation1.Key]; IMergeableAnnotation mergeableAnnotation = objA as IMergeableAnnotation; if (mergeableAnnotation != null) { CompatibilityResult compatibilityResult = mergeableAnnotation.IsCompatibleWith(annotation2); if (!(bool)compatibilityResult) { flag = false; ref string local = ref errorMessage; local = local + Environment.NewLine + "\t" + compatibilityResult.ErrorMessage; } } else if (!object.Equals(objA, annotation2)) { flag = false; ref string local = ref errorMessage; local = local + Environment.NewLine + "\t" + Strings.ConflictingAnnotationValue((object)annotation1.Key, (object)objA.ToString(), (object)annotation2.ToString()); } }
public static CompatibilityResult GetCompatibilityResult( PackageDetailsWithApiIndices package, string apiMethodSignature, string packageVersion, string target = "net6.0", 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); }
// event handlers... #region redirectButton_Click void redirectButton_Click(object sender, EventArgs e) { RedirectButton redirectButton = sender as RedirectButton; if (redirectButton == null) { return; } _Command = redirectButton.Command; _Parameters = redirectButton.Parameters; _Result = CompatibilityResult.ExecuteCommand; _PersistResponse = chkAlwaysPerformThisAction.Visible && chkAlwaysPerformThisAction.Checked; Close(); }
public static CompatibilityResult GetCompatibilityResult(PackageDetailsWithApiIndices package, CodeEntityDetails codeEntityDetails, string target = "net6.0", bool checkLesserPackage = false) { //If invocation, we will try to find it in a later package if (codeEntityDetails.CodeEntityType == CodeEntityType.Method) { if (string.IsNullOrEmpty(codeEntityDetails.Namespace)) { // codelyzer was not able to parse the symbol from the semantic model, so we can't accurately assess the compatibility. return(new CompatibilityResult { Compatibility = Compatibility.UNKNOWN, CompatibleVersions = new List <string>() }); } return(GetCompatibilityResult(package, codeEntityDetails.OriginalDefinition, codeEntityDetails.Package.Version, target, checkLesserPackage)); } //If another node type, we will not try to find it. Compatibility will be based on the package compatibility else { var compatibilityResult = new CompatibilityResult { Compatibility = Compatibility.UNKNOWN, CompatibleVersions = new List <string>() }; if (package == null || !NuGetVersion.TryParse(codeEntityDetails.Package.Version, out var targetversion)) { return(compatibilityResult); } if (package.PackageDetails.IsDeprecated) { compatibilityResult.Compatibility = Compatibility.DEPRECATED; return(compatibilityResult); } //For other code entities, we just need to check if the package has a compatible target: if (package.PackageDetails.Targets.ContainsKey(target)) { compatibilityResult.Compatibility = Compatibility.COMPATIBLE; return(compatibilityResult); } else { compatibilityResult.Compatibility = Compatibility.INCOMPATIBLE; } return(compatibilityResult); } }
public void Add(string columnName, IndexAttribute index) { if (this._columns.ContainsKey(index.Order)) { throw new InvalidOperationException(Strings.OrderConflictWhenConsolidating((object)index.Name, (object)this._table, (object)index.Order, (object)this._columns[index.Order], (object)columnName)); } this._columns[index.Order] = columnName; CompatibilityResult compatibilityResult = this._index.IsCompatibleWith(index, true); if (!(bool)compatibilityResult) { throw new InvalidOperationException(Strings.ConflictWhenConsolidating((object)index.Name, (object)this._table, (object)compatibilityResult.ErrorMessage)); } this._index = this._index.MergeWith(index, true); }
public static CompatibilityResult GetCompatibilityResult(CompatibilityResult compatibilityResultWithPackage, CompatibilityResult compatibilityResultWithSdk) { var compatiblityResult = compatibilityResultWithPackage; switch (compatibilityResultWithPackage.Compatibility) { case Compatibility.COMPATIBLE: break; case Compatibility.INCOMPATIBLE: if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE) { compatiblityResult = compatibilityResultWithSdk; } break; case Compatibility.DEPRECATED: if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE || compatibilityResultWithSdk.Compatibility == Compatibility.INCOMPATIBLE) { compatiblityResult = compatibilityResultWithSdk; } break; case Compatibility.UNKNOWN: if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE || compatibilityResultWithSdk.Compatibility == Compatibility.INCOMPATIBLE || compatibilityResultWithSdk.Compatibility == Compatibility.DEPRECATED) { compatiblityResult = compatibilityResultWithSdk; } break; default: break; } return(compatiblityResult); }
private void btnClose_Click(object sender, EventArgs e) { _Result = CompatibilityResult.Close; Close(); }
// event handlers... #region redirectButton_Click void redirectButton_Click(object sender, EventArgs e) { RedirectButton redirectButton = sender as RedirectButton; if (redirectButton == null) return; _Command = redirectButton.Command; _Parameters = redirectButton.Parameters; _Result = CompatibilityResult.ExecuteCommand; _PersistResponse = chkAlwaysPerformThisAction.Visible && chkAlwaysPerformThisAction.Checked; Close(); }
public static CompatibilityResult CheckCompatibility(bool verbose = false) { try { string productVersion = Assembly.GetEntryAssembly().GetProductVersion(); FlutterVersion flutterVersion = FlutterTools.GetVersion(verbose); SdkVersion sdk = AppSettings.Default.SdkTable.Versions.First(v => v.Version == productVersion); sdk.Compatibility.Sort(new SdkFlutterVersionComparer()); bool supported = false; // Indicates whether this SDK explicitly supports the installed Flutter version SdkFlutterVersion prev = null; // The last supported Flutter version that precedes the installed one (can be NULL) SdkFlutterVersion next = null; // The first supported Flutter version that follows the installed one (can be NULL) SdkFlutterVersion latest = null; // The latest supported Flutter version for (int i = 0; i < sdk.Compatibility.Count; i++) { SdkFlutterVersion fv = sdk.Compatibility[i]; int compare = VersionUtils.Compare(fv.Version, flutterVersion.Version); if (compare == 0) { supported = true; break; } if (compare < 0) { prev = fv; } else if (next == null) { next = fv; } if (i == sdk.Compatibility.Count - 1) { latest = fv; } } FlutterCompatibility compatibility; if (supported) { compatibility = FlutterCompatibility.Supported; } else if (prev != null) { compatibility = FlutterCompatibility.SupportNotGuaranteed; } else { compatibility = FlutterCompatibility.NotSupported; } CompatibilityResult result = new CompatibilityResult { Compatibility = compatibility, InstalledVersion = flutterVersion, NextSupportedVersion = next?.Version, LatestSupportedVersion = latest?.Version }; return(result); } catch (Exception ex) { Log.Ex(ex); Console.WriteLine(ex); throw; } }