Skip to content

Conversation

@jpobst
Copy link
Contributor

@jpobst jpobst commented Jul 11, 2023

There are several warnings when building Mono.Android.dll related to Obsolete methods:

warning CS0672: Member 'MediaRouteActionProvider.OnCreateActionView()' overrides obsolete member 'ActionProvider.OnCreateActionView()'. Add the Obsolete attribute to 'MediaRouteActionProvider.OnCreateActionView()'

Technically, MediaRouteActionProvider.onCreateActionView is marked as deprecated in the docs, but not in the compiled android.jar:

public class MediaRouteActionProvider extends ActionProvider {
  public View onCreateActionView() {
    throw new RuntimeException("Stub!");
  }
}

Regardless, any method that overrides a deprecated method should itself be marked as deprecated.

Another case specific to Mono.Android.dll is ContextWrapper.setWallpaper

This method is marked as deprecated-since = 23, but the base method is marked as deprecated-since = 16. This causes us to generate:

public class Context {
  [Obsolete]
  public virtual void SetWallpaper () { ... }
}

public class ContextWrapper : Context {
  [ObsoletedOSPlatform ("android23.0")]
  public override void SetWallpaper () { ... }
}

This causes the same warning. For these cases, we set the override method's deprecated-since to match the base method.

@jpobst jpobst marked this pull request as ready for review July 11, 2023 20:55
@jonpryor jonpryor merged commit d0231c5 into main Jul 12, 2023
@jonpryor jonpryor deleted the obsolete-consistency branch July 12, 2023 16:49
jonpryor pushed a commit to dotnet/android that referenced this pull request Jul 14, 2023
Fixes: dotnet/java-interop#1071

Context: dotnet/java-interop@d0231c5

Changes: dotnet/java-interop@e1121ea...151b03e

  * dotnet/java-interop@151b03ee: [Java.Interop.Tools.JavaSource] Improve `<code>` parsing  (dotnet/java-interop#1125)
  * dotnet/java-interop@6a9f5cbb: [Java.Interop.Tools.JavaSource] Improve `<a>` parsing (dotnet/java-interop#1126)
  * dotnet/java-interop@d0231c5c: [generator] Override methods should match base deprecated info (dotnet/java-interop#1130)

Commit dotnet/java-interop@d0231c5c updated `override` methods'
"obsolete" data to match its base method.  This results in several
`[ObsoleteOSPlatform]` attributes being switched to `[Obsolete]`
attributes.  Updated `acceptable-breakages` to allow this.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Pobst <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants