-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add back ObsoletedInOSPlatformAttribute
for net6
#47601
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
c.c. @terrajobst |
This moves our current/legacy attributes to the ones added in dotnet 5 [1]. Short Forms (only in bindings) | Old | New | |---------------------------------------|-------------------------------------| | [iOS (7,0)] | [SupportedOSPlatform ("ios7.0")] | | [NoIOS] | [UnsupportedOSPlatform ("ios")] | Long Forms | Old | New | |---------------------------------------|-------------------------------------| | [Introduced (PlatformName.iOS, 7,0)] | [SupportedOSPlatform ("ios7.0")] | | [Obsoleted (PlatformName.iOS, 12,1)] | [Obsolete (...)] | | [Deprecated (PlatformName.iOS, 14,3)] | [UnsupportedOSPlatform ("ios14.3")] | | [Unavailable (PlatformName.iOS)] | [UnsupportedOSPlatform ("ios")] | Other changes * `[SupportedOSPlatform]` and `[UnsupportedOSPlatform]` are not allowed on `interface` [2] which means they cannot be used for protocols. This is currently handled by inlining the existing attributes on all members. * `[ObsoletedInOSPlatform]` was removed in net5 RC. This PR is now mapping the existing attributes to `[Obsolote]`, however multiple ones cannot be added so they need to be platform specific. Still Missing * [ ] Generator deduplication of type/members attributes for interfaces (due to [2]) * [ ] Manual bindings * [ ] Introspection tests updates References * [1] xamarin#10170 * [2] dotnet/runtime#47599 * [3] dotnet/runtime#47601
…te` (#10580) This moves our current/legacy attributes to the ones added in dotnet 5 [1]. Short Forms (only in bindings) | Old | New | |---------------------------------------|-------------------------------------| | [iOS (7,0)] | [SupportedOSPlatform ("ios7.0")] | | [NoIOS] | [UnsupportedOSPlatform ("ios")] | Long Forms | Old | New | |---------------------------------------|-------------------------------------| | [Introduced (PlatformName.iOS, 7,0)] | [SupportedOSPlatform ("ios7.0")] | | [Obsoleted (PlatformName.iOS, 12,1)] | [Obsolete (...)] | | [Deprecated (PlatformName.iOS, 14,3)] | [UnsupportedOSPlatform ("ios14.3")] | | [Unavailable (PlatformName.iOS)] | [UnsupportedOSPlatform ("ios")] | Other changes * `[SupportedOSPlatform]` and `[UnsupportedOSPlatform]` are not allowed on `interface` [2] which means they cannot be used for protocols. This is currently handled by inlining the existing attributes on all members. * `[ObsoletedInOSPlatform]` was removed in net5 RC. This PR is now mapping the existing attributes to `[Obsolote]`, however multiple ones cannot be added so they need to be platform specific. Remaining work (manual bindings update) tracked in #11055 References * [1] #10170 * [2] dotnet/runtime#47599 * [3] dotnet/runtime#47601
@marek-safar Thoughts? |
It has been sitting here for 6 months so this is for @jeffhandley to prioritize now. |
During .NET 6, we ended up investing our time with the Platform Compatibility Analyzer into several other stories that had higher priorities and more compelling scenarios; as a result, we were not able to evaluate this story for .NET 6. While I understand that we don't have parity with previous functionality, I'm unconvinced that the
|
Agreed. That being said, I think it's reasonable to assume we'll be able to provide this for .NET 7. |
Before committing to it, I'd like to understand the value it provides more thoroughly. I expect it to have a large cost. |
Almost :-) It's for obsoleted, not deprecated, API. Most obsoleted API comes with replacement(s), which are part of the existing (pre-net6) attributes. E.g. [Obsoleted (PlatformName.iOS, 10,0, message: "Replaced by 'GColorConversionInfoTriple'.")] The current IDE tooling is showing this to developers at edit-time (not at build-time). For net6 we're mapping obsoleted API to This is not a perfect match since the platform is not clearly identified in the metadata. That means the message needs to be different to identify the platform/version where the obsolescence starts. Also since only a single #if __IOS__
[Obsolete ("Starting with ios14.0 Use 'CKQuerySubscriptionOptions' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif
#if __MACOS__
[Obsolete ("Starting with macos10.16 Use 'CKQuerySubscriptionOptions' instead.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")]
#endif which is not a problem for the generated code, but not very pleasant when manual bindings are needed. It's also reported at build-time, but with the recent
I'm not sure what the reaction to this change will be... it's a very old feature, there will be some muscle memory to retrain. I'm hoping people will prefer the new approach, since it has more tooling available and will be identical across all platforms. Anyway it's a bit too late to change anything so I suggest we keep our ears open for customer feedback. |
Thanks, @spouliot! I'll go ahead and close this, but we can certainly reopen it if we get feedback indicating we should revisit it. |
For future references, the following is a real example of what we have to do know: https://github.com/xamarin/xamarin-macios/pull/12365/files#diff-72574ede623de97723139c5b253475575f186431bd438834f73af5052587e91aR582 As you can see, is very verbose and error prone :( |
@mandel-macaque Thanks for sharing that example; that's helpful. If we were to do If you took the same approach of having a single, combined message, you'd having a single [Obsolete ("This API is removed starting in: maccatalyst15.0, ios15.0, tvos15.0, macos12.0. Please do not use.", DiagnosticId = "BI1234", UrlFormat = "https://github.com/xamarin/xamarin-macios/wiki/Obsolete")] Since that's the experience you'd get through |
Context: dotnet/android#6349 We are just noticing that we have this same issue in Xamarin - Android. Previously we have shipped N copied of Example: Thus public virtual void ClearDeviceOwnerApp (string packageName) { ... } while [Obsolete ("deprecated")]
public virtual void ClearDeviceOwnerApp (string packageName) { ... } In .NET6 we are shipping a single Currently this method shows as |
Here's an unfortunate developer scenario:
If we want to provide a good message to the user when they use the old API (telling them about the new API in iOS 15), we currently have to use the Obsolete attribute. However, this means that the user have to do something like this to have a warning-free build: #pragma warning disable 618
CalliOS14API ();
#pragma warning restore 618 adding a version check won't change anything: if (checkForiOS15) {
CalliOS15API ();
} else {
#pragma warning disable 618
CalliOS14API ();
#pragma warning restore 618
} I believe that adding a Put another way: using |
I've created an issue to request this API for .NET 7: #68557. |
Background and Motivation
Proposed API
Original specs
This was removed in 5.0 RC
dotnet/docs#20635 mention
With the addition of Xamarin SDK I think the need/time has come :-)
Usage Examples
Apple commonly obsoletes API and provide better alternatives for them. The headers (both C and Objective-C) includes macros that help developers (and the Xcode IDE) select the best API for the OS version being targeted.
The existing Xamarin SDKs (iOS/Mac) annotate the API with the similar attributes. This allow developers to identify which API are obsolete, well before they become deprecated (which generally means they will be rejected if submitted to one of the Apple App Stores).
The removal of
ObsoletedInOSPlatform
is blocking the completion of xamarin/xamarin-macios#10170Alternative Designs
None
Risks
The lack of this attribute means the analyzer can't have feature parity (regression) compared to the existing features available on VS.
The text was updated successfully, but these errors were encountered: