void ProcessObjcSelector(string fullname, VersionTuple objcVersion) { var class_method = fullname [0] == '+'; var n = fullname.IndexOf("::"); string objcClassName = fullname.Substring(class_method ? 1: 0, n); string selector = fullname.Substring(n + 2); TypeDefinition managedType = ManagedTypes.FirstOrDefault(x => Helpers.GetName(x) == objcClassName); if (managedType != null) { var framework = Helpers.GetFramework(managedType); if (framework == null) { return; } // If the entire type is deprecated, call it good enough if (AttributeHelpers.HasAnyDeprecationForCurrentPlatform(managedType)) { return; } var matchingMethod = managedType.Methods.FirstOrDefault(x => x.GetSelector() == selector && x.IsPublic && x.IsStatic == class_method); if (matchingMethod != null) { ProcessItem(matchingMethod, fullname, objcVersion, framework); } } }
void ProcessObjcSelector(string fullname, VersionTuple objcVersion) { string[] nameParts = fullname.Split(new string[] { "::" }, StringSplitOptions.None); string objcClassName = nameParts[0]; string selector = nameParts[1]; TypeDefinition managedType = ManagedTypes.FirstOrDefault(x => Helpers.GetName(x) == objcClassName); if (managedType != null) { var framework = Helpers.GetFramework(managedType); if (framework == null) { return; } // If the entire type is deprecated, call it good enough if (AttributeHelpers.HasAnyDeprecationForCurrentPlatform(managedType)) { return; } var matchingMethod = managedType.Methods.FirstOrDefault(x => x.GetSelector() == selector && x.IsPublic); if (matchingMethod != null) { ProcessItem(matchingMethod, fullname, objcVersion, framework); } } }
void ProcessObjcEntry(string objcClassName, VersionTuple objcVersion) { TypeDefinition managedType = ManagedTypes.FirstOrDefault(x => Helpers.GetName(x) == objcClassName && x.IsPublic); if (managedType != null) { var framework = Helpers.GetFramework(managedType); if (framework != null) { ProcessItem(managedType, Helpers.GetName(managedType), objcVersion, framework); } } }
public static Version Convert(VersionTuple version) { uint major = version.Major; uint minor = version.Minor.HasValue ? version.Minor.Value : 0; if (version.Subminor.HasValue) { return(new Version((int)major, (int)minor, (int)version.Subminor.Value)); } else { return(new Version((int)major, (int)minor)); } }
public static bool FindObjcDeprecated(IEnumerable <Attr> attrs, out VersionTuple version) { AvailabilityAttr attr = attrs.OfType <AvailabilityAttr> ().FirstOrDefault(x => !x.Deprecated.IsEmpty && x.Platform.Name == Helpers.ClangPlatformName); if (attr != null) { version = attr.Deprecated; return(true); } else { version = VersionTuple.Empty; return(false); } }
public void ProcessItem(ICustomAttributeProvider item, string itemName, VersionTuple objcVersion, string framework) { // Our bindings do not need have [Deprecated] for ancicent versions we don't support anymore if (VersionHelpers.VersionTooOldToCare(objcVersion)) { return; } // In some cases we've used [Advice] when entire types are deprecated // TODO - This is a hack, we shouldn't be doing ^ if (AttributeHelpers.HasAnyAdvice(item)) { return; } if (!AttributeHelpers.HasAnyDeprecationForCurrentPlatform(item)) { Log.On(framework).Add($"!deprecated-attribute-missing! {itemName} missing a [Deprecated] attribute"); return; } // Don't version check us when Apple does __attribute__((availability(macos, introduced=10.0, deprecated=100000))); // #define __API_TO_BE_DEPRECATED 100000 if (objcVersion.Major == 100000) { return; } // Some APIs have both a [Deprecated] and [Obsoleted]. Bias towards [Obsoleted]. Version managedVersion; bool foundObsoleted = AttributeHelpers.FindObsolete(item, out managedVersion); if (foundObsoleted) { if (managedVersion != null && !ManagedBeforeOrEqualToObjcVersion(objcVersion, managedVersion)) { Log.On(framework).Add($"!deprecated-attribute-wrong! {itemName} has {managedVersion} not {objcVersion} on [Obsoleted] attribute"); } return; } bool foundDeprecated = AttributeHelpers.FindDeprecated(item, out managedVersion); if (foundDeprecated && managedVersion != null && !ManagedBeforeOrEqualToObjcVersion(objcVersion, managedVersion)) { Log.On(framework).Add($"!deprecated-attribute-wrong! {itemName} has {managedVersion} not {objcVersion} on [Deprecated] attribute"); } }
public static bool VersionTooOldToCare(VersionTuple version) { switch (Helpers.Platform) { case Platforms.iOS: return(version.Major < 6); case Platforms.macOS: return(version.Minor < 7); case Platforms.tvOS: return(version.Major < 9); case Platforms.watchOS: return(version.Major < 2); default: throw new InvalidOperationException($"Unknown platform {Platform} in VersionTooOldToCare"); } }
void ProcessCFunction(string fullname, VersionTuple objcVersion) { if (dllimports.TryGetValue(fullname, out var method)) { var dt = method.DeclaringType; var framework = Helpers.GetFramework(dt); if (framework == null) { return; } // If the entire type is deprecated, call it good enough if (AttributeHelpers.HasAnyDeprecationForCurrentPlatform(dt)) { return; } ProcessItem(method, fullname, objcVersion, framework); } }
public static bool ManagedBeforeOrEqualToObjcVersion(VersionTuple objcVersionTuple, Version managedVersion) { // Often header files will soft deprecate APIs versions before a formal deprecation (10.7 soft vs 10.10 formal). Accept older deprecation values return(managedVersion <= VersionHelpers.Convert(objcVersionTuple)); }