From 6018db4d3913041ee9dcac23f5db5251ae075baf Mon Sep 17 00:00:00 2001 From: monojenkins Date: Mon, 5 Oct 2020 16:00:51 -0400 Subject: [PATCH] [xcode12.2] [tests][xtro] Consider class (static) methods when checking for deprecation. Fix #9026 (#9781) ref: https://github.com/xamarin/xamarin-macios/issues/9026 --- tests/xtro-sharpie/DeprecatedCheck.cs | 13 +++++++++---- tests/xtro-sharpie/common-CoreBluetooth.ignore | 1 - tests/xtro-sharpie/common-CoreLocation.ignore | 5 ----- tests/xtro-sharpie/macOS-CoreLocation.ignore | 4 ---- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/xtro-sharpie/DeprecatedCheck.cs b/tests/xtro-sharpie/DeprecatedCheck.cs index 0dbe76f52b..1202ddbb12 100644 --- a/tests/xtro-sharpie/DeprecatedCheck.cs +++ b/tests/xtro-sharpie/DeprecatedCheck.cs @@ -59,8 +59,9 @@ namespace Extrospection void ProcessObjcSelector (string fullname, VersionTuple objcVersion) { + var class_method = fullname [0] == '+'; var n = fullname.IndexOf ("::"); - string objcClassName = fullname.Substring (0, n); + string objcClassName = fullname.Substring (class_method ? 1: 0, n); string selector = fullname.Substring (n + 2); TypeDefinition managedType = ManagedTypes.FirstOrDefault (x => Helpers.GetName (x) == objcClassName); @@ -73,7 +74,7 @@ namespace Extrospection if (AttributeHelpers.HasAnyDeprecationForCurrentPlatform (managedType)) return; - var matchingMethod = managedType.Methods.FirstOrDefault (x => x.GetSelector () == selector && x.IsPublic); + var matchingMethod = managedType.Methods.FirstOrDefault (x => x.GetSelector () == selector && x.IsPublic && x.IsStatic == class_method); if (matchingMethod != null) ProcessItem (matchingMethod, fullname, objcVersion, framework); } @@ -152,8 +153,12 @@ namespace Extrospection public override void VisitObjCMethodDecl (ObjCMethodDecl decl, VisitKind visitKind) { - if (visitKind == VisitKind.Enter && AttributeHelpers.FindObjcDeprecated(decl.Attrs, out VersionTuple version)) - ObjCDeprecatedSelectors[decl.QualifiedName] = version; + if (visitKind == VisitKind.Enter && AttributeHelpers.FindObjcDeprecated (decl.Attrs, out VersionTuple version)) { + var qn = decl.QualifiedName; + if (decl.IsClassMethod) + qn = "+" + qn; + ObjCDeprecatedSelectors [qn] = version; + } } public override void VisitFunctionDecl (FunctionDecl decl, VisitKind visitKind) diff --git a/tests/xtro-sharpie/common-CoreBluetooth.ignore b/tests/xtro-sharpie/common-CoreBluetooth.ignore index de0181cb26..7970aa36a3 100644 --- a/tests/xtro-sharpie/common-CoreBluetooth.ignore +++ b/tests/xtro-sharpie/common-CoreBluetooth.ignore @@ -12,7 +12,6 @@ !missing-selector! CBCentralManager::init not bound ## short lived instance property being replaced with a static one -!deprecated-attribute-missing! CBManager::authorization missing a [Deprecated] attribute !missing-selector! CBManager::authorization not bound # Initial result from new rule missing-null-allowed diff --git a/tests/xtro-sharpie/common-CoreLocation.ignore b/tests/xtro-sharpie/common-CoreLocation.ignore index f837c64e18..49609f247f 100644 --- a/tests/xtro-sharpie/common-CoreLocation.ignore +++ b/tests/xtro-sharpie/common-CoreLocation.ignore @@ -1,11 +1,6 @@ # We have our own managed ctor !missing-pinvoke! CLLocationCoordinate2DMake is not bound -# xtro is confused because objc has two properties with the same name on objc, one static and the other one an instance one. -# we did add the deprecation in the correct one. Reported issue: https://github.com/xamarin/xamarin-macios/issues/9026 -!deprecated-attribute-missing! CLLocationManager::authorizationStatus missing a [Deprecated] attribute - - ## unsorted !missing-field! kCLHeadingFilterNone not bound diff --git a/tests/xtro-sharpie/macOS-CoreLocation.ignore b/tests/xtro-sharpie/macOS-CoreLocation.ignore index 6736018bbe..931e2e16e5 100644 --- a/tests/xtro-sharpie/macOS-CoreLocation.ignore +++ b/tests/xtro-sharpie/macOS-CoreLocation.ignore @@ -13,7 +13,3 @@ !missing-selector! CLLocationManager::startMonitoringForRegion:desiredAccuracy: not bound !missing-selector! CLLocationManager::allowDeferredLocationUpdatesUntilTraveled:timeout: not bound !missing-selector! CLLocationManager::disallowDeferredLocationUpdates not bound - -# xtro confuse the instance vs the class property -!deprecated-attribute-missing! CLLocationManager::locationServicesEnabled missing a [Deprecated] attribute -!deprecated-attribute-missing! CLLocationManager::headingAvailable missing a [Deprecated] attribute