Skip to content

Conversation

@jpobst
Copy link
Contributor

@jpobst jpobst commented Aug 15, 2022

Context: dotnet/android#7234

Add support for a new lang-features=obsoleted-platform-attributes generator option.

When used, for API that was obsoleted in API levels greater than our .NET 7 minimum (API 21), we will generate .NET 7's new [ObsoletedOSPlatform] attribute instead of [Obsolete]:

// New
[global::System.Runtime.Versioning.ObsoletedOSPlatform ("android22.0", @"This class is obsoleted in this android platform")]
public partial class CookieSpecParamBean : Org.Apache.Http.Params.HttpAbstractParamBean { ... }

// Previous
[global::System.Obsolete (@"This class is obsoleted in this android platform")]
public partial class CookieSpecParamBean : Org.Apache.Http.Params.HttpAbstractParamBean { ... }

This is useful for a .NET 7+ context because we always compile against a "latest" Mono.Android, even if you are targeting an earlier version. For example, this causes the above class to throw an obsolete warning even if you are using $(SupportedOSPlatformVersion)=21.

Companion XA test PR: dotnet/android#7266

@jpobst jpobst force-pushed the obsoleted-os-platform branch from 9fcddcd to dede5ac Compare August 15, 2022 21:21
@jpobst jpobst force-pushed the obsoleted-os-platform branch from dede5ac to d2916d8 Compare August 16, 2022 13:55
@jpobst jpobst marked this pull request as ready for review August 23, 2022 19:00
@jonpryor jonpryor merged commit d3ea180 into main Aug 23, 2022
@jonpryor jonpryor deleted the obsoleted-os-platform branch August 23, 2022 19:12
@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