-
Notifications
You must be signed in to change notification settings - Fork 54
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
Invokers should emit [SupportedOSPlatformAttribute]
#863
Comments
jonpryor
pushed a commit
that referenced
this issue
Aug 27, 2021
Fixes: #863 In commits da12df4 and 412e974 (and others) we added support to emit the `[SupportedOSPlatformAttribute]` custom attribute when targeting .NET 6+ builds, using the Android API-level that the member was introduced: [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")] [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] public abstract partial class InCallService : Android.App.Service { } However, our "invoke" machinery uses this API without having the same guards: [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] internal partial class InCallServiceInvoker : InCallService { } This results in build warnings when building e.g. `xamarin-android/src/Mono.Android`: …/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-30/mcw/Android.Telecom.InCallService.cs(1287,76): warning CA1416: This call site is reachable on all platforms. 'InCallService' is only supported on: 'android' 23.0 and later. To fix these warnings, we need to emit the same `[SupportedOSPlatformAttribute]` for these members as well: [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")] [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] internal partial class InCallServiceInvoker : InCallService { } This change removes 4,699 `CA1416` warnings from our `Mono.Android.dll` build. The remaining 61 `CA1416` warnings are of the form: …\xamarin-android\src\Mono.Android\obj\Debug\net6.0\android-31\mcw\Java.Lang.Reflect.Method.cs(35,71): warning CA1416: This call site is reachable on all platforms. 'Executable' is only supported on: 'android' 26.0 and later. The problem here is that `Java.Lang.Reflect.Method` class is available since API-1, but it inherits from the `Java.Lang.Reflect.Executable` class which was added in API-26. See: - https://developer.android.com/reference/java/lang/reflect/Method - https://developer.android.com/reference/java/lang/reflect/Executable This seems like a `Mono.Android.dll` issue and not something we should attempt to fix in `generator`.
jonpryor
pushed a commit
to dotnet/android
that referenced
this issue
Sep 8, 2021
Fixes: dotnet/java-interop#863 Changes: dotnet/java-interop@b7982e4...f359e73 * dotnet/java-interop@f359e731: [generator] Generate more [SupportedOSPlatform] attributes (#868)
jpobst
added a commit
that referenced
this issue
Sep 30, 2021
Fixes: #863 In commits da12df4 and 412e974 (and others) we added support to emit the `[SupportedOSPlatformAttribute]` custom attribute when targeting .NET 6+ builds, using the Android API-level that the member was introduced: [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")] [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] public abstract partial class InCallService : Android.App.Service { } However, our "invoke" machinery uses this API without having the same guards: [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] internal partial class InCallServiceInvoker : InCallService { } This results in build warnings when building e.g. `xamarin-android/src/Mono.Android`: …/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-30/mcw/Android.Telecom.InCallService.cs(1287,76): warning CA1416: This call site is reachable on all platforms. 'InCallService' is only supported on: 'android' 23.0 and later. To fix these warnings, we need to emit the same `[SupportedOSPlatformAttribute]` for these members as well: [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android23.0")] [global::Android.Runtime.Register ("android/telecom/InCallService", DoNotGenerateAcw=true, ApiSince = 23)] internal partial class InCallServiceInvoker : InCallService { } This change removes 4,699 `CA1416` warnings from our `Mono.Android.dll` build. The remaining 61 `CA1416` warnings are of the form: …\xamarin-android\src\Mono.Android\obj\Debug\net6.0\android-31\mcw\Java.Lang.Reflect.Method.cs(35,71): warning CA1416: This call site is reachable on all platforms. 'Executable' is only supported on: 'android' 26.0 and later. The problem here is that `Java.Lang.Reflect.Method` class is available since API-1, but it inherits from the `Java.Lang.Reflect.Executable` class which was added in API-26. See: - https://developer.android.com/reference/java/lang/reflect/Method - https://developer.android.com/reference/java/lang/reflect/Executable This seems like a `Mono.Android.dll` issue and not something we should attempt to fix in `generator`.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We began emitting
[SupportedOSPlatformAttribute]
fornet6.0
Mono.Android.dll
public API:However our
internal
machinery uses this API without having the same guards:This results in warnings:
We need to emit the same
[SupportedOSPlatformAttribute]
for these methods as well.The text was updated successfully, but these errors were encountered: