Skip to content

Add SuppressLinkerWarningAttribute #35339

Closed

Description

@MichalStrehovsky

This is in support of dotnet/linker#988 - see the spec there for motivation.

We need a way to selectively suppress warnings about linker-unfriendly patterns.

This attribute is largely inspired by SuppressMessageAttribute (that unfortunately cannot be used because it's marked [Conditional] under a condition that we wouldn't expect to enable when the linker runs).

namespace System.Runtime.CompilerServices
{
    [AttributeUsage(
     AttributeTargets.All,
     Inherited = false,
     AllowMultiple = true
     )
    ]
    public sealed class SuppressLinkerWarningAttribute : Attribute
    {
        public SuppressLinkerWarningAttribute(string category, string checkId)
        {
            Category = category;
            CheckId = checkId;
        }

        public string Category { get; }
        public string CheckId { get; }
        public string? MessageId { get; set; }
        public string? Justification { get; set; }
    }
}

Activity

  1. added
    linkable-framework
    on Apr 23, 2020
  2. added this to the 5.0 milestone on Apr 23, 2020
  3. added
    untriaged
    on Apr 23, 2020
  4. MichalStrehovsky commented on Apr 23, 2020

    @MichalStrehovsky
    MemberAuthor
  5. added
    api-approved
    and removed on Apr 23, 2020
  6. terrajobst commented on Apr 23, 2020

    @terrajobst
    Contributor

    Video

    • We should position it as a peer to SuppressMessageAttribute, UnconditionalSuppressMessageAttribute
    • It should be System.Diagnostics.CodeAnalysis
    • The behavior is the same, except it's not marked [Conditonal] and thus will always remain in metadata
    • We considered establishing an inheritance relationshop with SuppressMessageAttribute but concluded we don't need it (neither for docs nor for consumption)
    namespace System.Diagnostics.CodeAnalysis
    {
        [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
        public sealed class UnconditionalSuppressMessageAttribute : Attribute
        {
        	// Same API as SuppressMessageAttribute
        }
    }
  7. self-assigned this
    on Apr 23, 2020
  8. eerhardt commented on Apr 28, 2020

    @eerhardt
    Member

    Closed in #35387.

  9. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
  10. removed
    untriaged
    on Jun 24, 2024
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.Runtimelinkable-framework

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions