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 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)); }