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

Extend ObsoleteAttribute #33089

Closed
terrajobst opened this issue Mar 3, 2020 · 2 comments
Closed

Extend ObsoleteAttribute #33089

terrajobst opened this issue Mar 3, 2020 · 2 comments
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime
Milestone

Comments

@terrajobst
Copy link
Member

terrajobst commented Mar 3, 2020

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
    {
        // ...
    }
}
@terrajobst terrajobst added api-ready-for-review blocked Issue/PR is blocked on something - see comments labels Mar 3, 2020
@terrajobst terrajobst self-assigned this Mar 3, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Mar 3, 2020
@terrajobst terrajobst added blocking Marks issues that we want to fast track in order to unblock other important work and removed blocked Issue/PR is blocked on something - see comments labels Mar 3, 2020
@terrajobst terrajobst added this to the 5.0 milestone Mar 3, 2020
@terrajobst terrajobst removed the untriaged New issue has not been triaged by the area owner label Mar 3, 2020
@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review labels Mar 3, 2020
@terrajobst terrajobst removed their assignment Mar 3, 2020
@terrajobst terrajobst removed the blocking Marks issues that we want to fast track in order to unblock other important work label Mar 6, 2020
@terrajobst
Copy link
Member Author

Resolved by #33248

@GrabYourPitchforks
Copy link
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?

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Runtime
Projects
None yet
Development

No branches or pull requests

5 participants