-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Obsolete attribute used instead of ObsoletedOSPlatform attribute #7558
Comments
Implemented in #7234 |
Some of them were deprecated before our minimum API level (21), so they are just marked with the regular
The others were obsoleted in API-33, so they should have the new attribute. Maybe there is something messed up because we have converted the |
This causes a compile error in our Xamarin.Forms apps on Azure DevOps windows-2022 images.
This is weird since that signature should be the one that isn't deprecated: The deprecated one is the int flags overload: But there appears to be no overload for ( So this is surely something that needs to be addressed as early as Xamarin.Android, let along NET6/7/8. |
This appears to be a case of us making an unfortunate name choice a long time ago. The original methods from Google are:
We want our APIs to be a little easier to use, so we converted the
In API-33, it looks like Google has done the same thing we did and introduced new overloads that take an "enum-like" Java type:
Note that instead of our enum Thus you have to look closer to see that methods that take the enum
|
We don't. We actually use [Obsolete] ourselves, which generates We're going to suppress it in code with |
This may also apply to |
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
VS 2022 17.4.1, .NET 7
Description
I am using this property to get the installed app version:
The old (now deprecated)
GetPackageInfo
method still emits this warning, even thoughOperatingSystem.IsAndroidVersionAtLeast
is used:Warning CS0618 'PackageManager.GetPackageInfo(string, PackageInfoFlags)' is obsolete: 'deprecated'
This is because of this attribute:
[System.Obsolete("deprecated")]
I think this attribute should be used instead:
[ObsoletedOSPlatform("android30.0")]
I know this is rather nitpicking, but there might be other usages of the old
Obsolete
attribute that could be replaced with theObsoletedOSPlatform
attribute. In the PackageManager class alone there are also these methods currently annotated with the old attribute:https://developer.android.com/reference/android/content/pm/PackageManager#addPreferredActivity(android.content.IntentFilter,%20int,%20android.content.ComponentName[],%20android.content.ComponentName)
https://developer.android.com/reference/android/content/pm/PackageManager#getPackageGids(java.lang.String,%20int)
https://developer.android.com/reference/android/content/pm/PackageManager#removePackageFromPreferred(java.lang.String)
https://developer.android.com/reference/android/content/pm/PackageManager#addPackageToPreferred(java.lang.String)
Steps to Reproduce
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: