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

[Meta] List of APIs considered for "Better Obsoletion" #33360

Closed
Joe4evr opened this issue Mar 9, 2020 · 11 comments
Closed

[Meta] List of APIs considered for "Better Obsoletion" #33360

Joe4evr opened this issue Mar 9, 2020 · 11 comments
Labels
area-Meta enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@Joe4evr
Copy link
Contributor

Joe4evr commented Mar 9, 2020

Rationale

Immo Landwerth (@terrajobst) has proposed a mechanism to improve obsoleting APIs by extending ObsoleteAttribute, affectionally known as Better Obsoletion. Recently, that proposed addition was merged into the framework and the compilers honor the new properties as of dotnet/roslyn#42518. In light of this, it seems like a good idea to gather a list of APIs that should be considered for Better Obsoletion, so there's a central place to discuss/review/suggest these.

Obsolete APIs

This list is by no means exhaustive, but it'll kickstart the discussion.

The three examples from the design doc:

A quick search for 'obsolete' in dotnet/runtime revealed these:

Other APIs to be considered:

@Kryptos-FR
Copy link

There was an issue I opened a while ago regarding ArrayList in .Net Standard (dotnet/standard#296).

Which leads me to the question: would that obsoletion also be applied to the standard, or only to .NET5?

@Joe4evr
Copy link
Contributor Author

Joe4evr commented Mar 13, 2020

@Kryptos-FR The idea of .NET Standard was to unify the API surface area across multiple implementations of the .NET runtime. With .NET 5 being the unification of those to a single runtime implementation, the purpose of .NET Standard loses its meaning in that new world.

As such, don't hold your breath on the Standard still evolving.

@joperezr joperezr added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels Jul 7, 2020
@joperezr joperezr added this to the Future milestone Jul 7, 2020
@jeffhandley
Copy link
Member

We created dotnet/designs#139, which includes a few APIs mentioned here.

@slavanap
Copy link

Can I obsolete specific objects from another library (including .NET itself) in my project, if they aren't obsoleted in their source?

@chucker
Copy link

chucker commented Jul 18, 2020

You can write an analyzer. Consider forking https://github.com/dotnet/platform-compat

@slavanap
Copy link

@chucker is it correct if I would ever want to restrict some API usages in my project, I would need to build custom analyzer for it which I would later use for code check?

@Joe4evr
Copy link
Contributor Author

Joe4evr commented Jul 18, 2020

@slavanap For code that you own, you can simply apply [Obsolete] with your own value for the new DiagnosticId property.

@slavanap
Copy link

What about the case when I want to restrict usage of implicit operator, code of which I do not own?

@jeffhandley
Copy link
Member

jeffhandley commented Jul 18, 2020

You can write an analyzer. Consider forking https://github.com/dotnet/platform-compat

Note that we are working to fully productize the platform-compat analyzer, to get it integrated into the .NET SDK for .NET 5. It will use the new platform-specific support attributes and respect the new IsOSPlatformOrLater and IsOSPlatformEarlierThan methods.

Here's the draft PR from @buyaa-n if you're curious; we expect the PR into dotnet/runtime will be created within the next couple weeks.

@slavanap Other than including an analyzer in your package as was suggested, there isn't a way to cast [Obsolete] attributes onto APIs exposed from one of your dependencies (or the .NET Libraries).

@jeffhandley
Copy link
Member

Ha -- my goodness, I got my wires crossed on the previous comment, @slavanap, and I referenced the wrong attributes that the Platform Compat Analyzer will be using. I've fixed the comment above to be accurate.

@jeffhandley
Copy link
Member

With the bulk of these issues now addressed, I'm going to close this issue. #46767 captured the obsoletions completed in .NET 6 and I filed #57207 to capture the remaining items from that list and this one for carrying forward into .NET 7.

Thanks for originally filing this, @Joe4evr--this was a big help to steer our efforts and shape our obsoletion work.

@ghost ghost added the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Aug 11, 2021
@jeffhandley jeffhandley removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Aug 11, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta enhancement Product code improvement that does NOT require public API changes/additions
Projects
No open projects
Development

No branches or pull requests

7 participants