Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api-merge] Correctly compute //method/@deprecated-since (#7645)
Fixes: #7558 Context: xamarin/monodroid@16338f9 Context: a073d99 Context: 938c349 Currently when `api-merge` loops through type members, its first check is to see if there is any existing member with the same name. If there isn't, it can short-circuit, add the new member, and move to the next one. If there is, we compare the existing API level member to the new API level one to see if it has been marked deprecated in this level, and if so we can add the `deprecated-since` attribute. However, this initial existing member check was solely done on member *name*, not signature. 😱 If the member is a method, a later check finds the exact matching method with the same signature. We were performing the `deprecated-since` logic against the first method with a matching name rather than the method with the same signature. Consider [`PackageManager.getPackageInfo(String, int)`][0], which was deprecated in *API-33*. Yet our binding emitted `[Obsolete]`, meaning it has been deprecated since API-21 or before! namespace Android.Content.PM; partial class PackageManager { [global::System.Obsolete (@"deprecated")] [Register ("getPackageInfo", "(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;", "GetGetPackageInfo_Ljava_lang_String_IHandler")] public override unsafe Android.Content.PM.PackageInfo? GetPackageInfo (string packageName, [global::Android.Runtime.GeneratedEnum] Android.Content.PM.PackageInfoFlags flags) => … } This was wrong; it should instead have used `[ObsoletedOSPlatform]`: namespace Android.Content.PM; partial class PackageManager { [global::System.Runtime.Versioning.ObsoletedOSPlatform ("android33.0")] [Register ("getPackageInfo", "(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;", "GetGetPackageInfo_Ljava_lang_String_IHandler")] public override unsafe Android.Content.PM.PackageInfo? GetPackageInfo (string packageName, [global::Android.Runtime.GeneratedEnum] Android.Content.PM.PackageInfoFlags flags) => … } Move the `UpdateDeprecatedSince()` invocations to be called *after* we have the method with the matching signature. The `acceptable-breakages` changes reflect additional `[Obsolete]` attributes that are now being converted to `[ObsoletedOSPlatform ("android-XX.0")]` attributes. [0]: https://developer.android.com/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20int)
- Loading branch information