Skip to content

Cannot suppress obsolete or experimental errors that use a custom diagnostic ID #114377

Open
@anthonymastreanvae

Description

@anthonymastreanvae

Description

I cannot suppress obsolete or experimental errors that use a custom diagnostic ID with a local or global suppress message attribute. Only preprocessor directives and Global AnalyzerConfig seems to work... but I can't always use those options (for example in some compliance & regulatory situations).

Reproduction Steps

using System.Diagnostics.CodeAnalysis;

namespace N;

[Experimental("EXAMPLE0001")]
public class A
{
}

[Obsolete("B is obsolete", DiagnosticId = "EXAMPLE0002")]
public class B
{
}

public class C
{
    [SuppressMessage("", "EXAMPLE0001")]
    private readonly A c;

    [SuppressMessage("", "EXAMPLE0002")]
    private readonly B b;
}

Expected behavior

I expect to be able to use the SuppressMessageAttribute locally or globally to suppress the custom diagnostic ID.

Actual behavior

I am unable to use the SuppressMessageAttribute locally or globally to suppress the custom diagnostic ID.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions