Skip to content

Extend ObsoleteAttribute #33089

Closed
Closed

Description

@terrajobst

We'd like to make obsoletion more viable. This requires extending the ObsoleteAttribute:

API

#nullable enable
namespace System
{
    public partial class ObsoleteAttribute : Attribute
    {
        // Existing:
        //
        // public ObsoleteAttribute();
        // public ObsoleteAttribute(string message);
        // public ObsoleteAttribute(string message, bool error);
        // public bool IsError { get; }
        // public string Message { get; }

        // New:
        public string? DiagnosticId { get; set; }
        public string? UrlFormat { get; set; }
    }
}

Usage

namespace System.Collections
{
    [Obsolete(DiagnosticId="BCL0006", UrlFormat="https://aka.ms/obsolete/{0}")]
    public class ArrayList
    {
        // ...
    }

    [Obsolete(DiagnosticId="BCL0006", UrlFormat="https://aka.ms/obsolete/{0}")]
    public class Stack
    {
        // ...
    }
}
namespace System.Security
{
    [Obsolete(DiagnosticId"BCL0001", UrlFormat="https://aka.ms/obsolete/{0}")]
    public sealed class SecureString
    {
        // ...
    }
}

Activity

  1. added
    blocked
    on Mar 3, 2020
  2. self-assigned this
    on Mar 3, 2020
  3. added
    untriaged
    on Mar 3, 2020
  4. added
    blocking
    and removed
    blocked
    on Mar 3, 2020
  5. added this to the 5.0 milestone on Mar 3, 2020
  6. removed
    untriaged
    on Mar 3, 2020
  7. added
    api-approved
    and removed on Mar 3, 2020
  8. removed their assignment
    on Mar 3, 2020
  9. removed
    blocking
    on Mar 6, 2020
  10. terrajobst commented on Mar 6, 2020

    @terrajobst
    ContributorAuthor

    Resolved by #33248

  11. GrabYourPitchforks commented on May 15, 2020

    @GrabYourPitchforks
    Member

    BTW I'm experimenting with using the UrlFormat property for new obsolete messages, and it's running afoul of CA2243.

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	CA2243	In the constructor of 'ObsoleteAttribute', change the value of argument 'ObsoleteAttribute.UrlFormat', which is currently "https://aka.ms/dotnet-obsoletions/fill-me-in/{0}", to something that can be correctly parsed as 'Uri'.	System.Runtime.Serialization.Formatters (net5.0-Unix), System.Runtime.Serialization.Formatters (net5.0-Windows_NT)	C:\runtime.titan\src\libraries\System.Runtime.Serialization.Formatters\src\System\Runtime\Serialization\Formatters\Binary\BinaryFormatter.cs	41	Active

    We should update CA2243 to be aware of this particular property and to ignore it, or we should suppress CA2243 globally throughout the runtime repo, or we should rename the property to something other than UrlFormat.

    Any preference as to these courses of action?

  12. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedarea-System.Runtime

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions