Skip to content

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

Closed

Description

@Joe4evr

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:

Activity

  1. added
    untriaged
    on Mar 9, 2020
  2. Kryptos-FR commented on Mar 12, 2020

    @Kryptos-FR

    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?

  3. Joe4evr commented on Mar 13, 2020

    @Joe4evr
    ContributorAuthor

    @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.

  4. added
    enhancement
    and removed
    untriaged
    on Jul 7, 2020
  5. added this to the Future milestone on Jul 7, 2020
  6. jeffhandley commented on Jul 13, 2020

    @jeffhandley
    Member

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

  7. slavanap commented on Jul 18, 2020

    @slavanap

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

  8. chucker commented on Jul 18, 2020

    @chucker
  9. slavanap commented on Jul 18, 2020

    @slavanap

    @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?

  10. Joe4evr commented on Jul 18, 2020

    @Joe4evr
    ContributorAuthor

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

  11. slavanap commented on Jul 18, 2020

    @slavanap

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

  12. jeffhandley commented on Jul 18, 2020

    @jeffhandley
    Member

    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).

  13. jeffhandley commented on Jul 21, 2020

    @jeffhandley
    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.

  14. jeffhandley commented on Aug 11, 2021

    @jeffhandley
    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.

  15. ghost added
    needs-further-triage
    on Aug 11, 2021
  16. removed
    needs-further-triage
    on Aug 11, 2021
  17. ghost locked as resolved and limited conversation to collaborators on Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Metaenhancement

    Type

    No type

    Projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions