Skip to content
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

Make use of the new ObsoletedOSPlatformAttribute in .NET 7 #15849

Closed
rolfbjarne opened this issue Sep 2, 2022 · 4 comments
Closed

Make use of the new ObsoletedOSPlatformAttribute in .NET 7 #15849

rolfbjarne opened this issue Sep 2, 2022 · 4 comments
Labels
dotnet An issue or pull request related to .NET (6) enhancement The issue or pull request is an enhancement
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented Sep 2, 2022

Ref: dotnet/runtime#68557
Note that the attribute was renamed after it was added, to ObsoletedOSPlatformAttribute (dotnet/runtime#72970)

I think our change is mostly changing our [Obsolete (...)] attributes for .NET to use the new ObsoletedOSPlatform [...] attribute.

We should also likely document how we map Apple's availability attributes to .NET's availability attributes, because it's not entirely obvious:

Apple .NET
Introduced SupportedOSPlatform ("ios15.0")
Obsoleted UnsupportedOSPlatform ("ios16.0")
Deprecated ObsoletedOSPlatform ("ios17.0")
Unavailable UnsupportedOSPlatform ("ios")

Additionally we should use the new Message property on the UnsupportedOSPlatform attribute (instead of using an Obsolete attribute to give this information).

@rolfbjarne rolfbjarne added enhancement The issue or pull request is an enhancement dotnet An issue or pull request related to .NET (6) labels Sep 2, 2022
@rolfbjarne rolfbjarne added this to the .NET 7 milestone Sep 2, 2022
@chamons
Copy link
Contributor

chamons commented Sep 7, 2022

So looking at this, I think there are two major parts, one very cheap and one that will require some manual work:

  • For NET6 generator targets we should be able to generate the new ObsoletedOSPlatformAttribute attribute pretty easily, and I'll take a stab.
  • However, we have a non-trivial amount of non-generator processed code, which might have obsolete attributes that need to be converted by hand. I expect the number is too small to need a pass with mellite, and will just need a nullability like pass.

@rolfbjarne
Copy link
Member Author

BTW this needs to target the net7.0 branch (not main)

@rolfbjarne
Copy link
Member Author

I think 2. should be fairly easy to grep for:

$ git grep Obsolete.*Starting
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveInterruption' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveInterruption' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveAudioRouteChange' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveAudioRouteChange' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveAudioRouteChange' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
src/AVFoundation/Events.cs:             [Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveAudioRouteChange' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
...

and the change would be to change this:

#if IOS
[Obsolete ("Starting with ios6.0 use 'AVAudioSession.Notification.ObserveInterruption' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif

to:

[ObsoletedOSPlatform ("ios6.0", "Use 'AVAudioSession.Notification.ObserveInterruption' instead.")]

(and removing the #if IOS condition)

chamons added a commit to chamons/xamarin-macios that referenced this issue Sep 12, 2022
chamons added a commit to chamons/xamarin-macios that referenced this issue Sep 13, 2022
chamons added a commit that referenced this issue Sep 20, 2022
…to use 'ObsoletedOSPlatform' (#15953)

- Part of #15849
- These were done with a few vim macros and some manual edits, so
mistakes are possibly but new typos are less likely.
chamons added a commit that referenced this issue Oct 6, 2022
…15941)

- Part of #15849
- A bit of dead code was removed while I was reviewing things.

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
@chamons
Copy link
Contributor

chamons commented Oct 10, 2022

I believe this is all complete!

@chamons chamons closed this as completed Oct 10, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dotnet An issue or pull request related to .NET (6) enhancement The issue or pull request is an enhancement
Projects
None yet
Development

No branches or pull requests

2 participants